MCPcopy Create free account
hub / github.com/Virtual-Protocol/virtuals-python / post

Function post

src/virtuals_sdk/game/utils.py:22–48  ·  view source on GitHub ↗

API call to post data

(base_url: str, api_key: str, endpoint: str, data: dict)

Source from the content-addressed store, hash-verified

20
21
22def post(base_url: str, api_key: str, endpoint: str, data: dict) -> dict:
23 """
24 API call to post data
25 """
26 access_token = get_access_token(api_key)
27
28 response = requests.post(
29 f"{base_url}/prompts",
30 json={
31 "data":
32 {
33 "method": "post",
34 "headers": {
35 "Content-Type": "application/json",
36 },
37 "route": endpoint,
38 "data": data,
39 },
40 },
41 headers={"Authorization": f"Bearer {access_token}"},
42 )
43
44 response_json = response.json()
45 if response.status_code != 200:
46 raise ValueError(f"Failed to post data: {response_json}")
47
48 return response_json["data"]
49
50
51def create_agent(

Callers 5

_get_actionMethod · 0.90
set_taskMethod · 0.90
_get_actionMethod · 0.90
create_agentFunction · 0.85
create_workersFunction · 0.85

Calls 1

get_access_tokenFunction · 0.85

Tested by

no test coverage detected