Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/opengradient/client/twins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Twins:

Usage:
twins = og.Twins(api_key="your-api-key")
response = twins.chat(
response = await twins.chat(
twin_id="0x1abd463fd6244be4a1dc0f69e0b70cd5",
model=og.TEE_LLM.GROK_4_1_FAST_NON_REASONING,
messages=[{"role": "user", "content": "What do you think about AI?"}],
Expand All @@ -30,7 +30,7 @@ class Twins:
def __init__(self, api_key: str):
self._api_key = api_key

def chat(
async def chat(
self,
twin_id: str,
model: TEE_LLM,
Expand Down Expand Up @@ -70,7 +70,8 @@ def chat(
payload["max_tokens"] = max_tokens

try:
response = httpx.post(url, json=payload, headers=headers, timeout=60)
async with httpx.AsyncClient() as client:
response = await client.post(url, json=payload, headers=headers, timeout=60)
response.raise_for_status()
result = response.json()

Expand Down