Skip to main content

SDKs & Clients

CleverThis's inference API is a drop-in replacement for the OpenAI API. Any OpenAI-compatible client library works by changing two values: the base URL and the API key.

Python (openai SDK)

from openai import OpenAI

client = OpenAI(
api_key="ct_live_YOUR_KEY",
base_url="https://api.cleverthis.com/v1",
)

# Chat completion
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello, CleverThis!"}],
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Count to 10"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")

TypeScript / JavaScript (openai SDK)

import OpenAI from "openai";

const client = new OpenAI({
apiKey: "ct_live_YOUR_KEY",
baseURL: "https://api.cleverthis.com/v1",
});

const response = await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello, CleverThis!" }],
});

console.log(response.choices[0].message.content);

curl

# Non-streaming
curl https://api.cleverthis.com/v1/chat/completions \
-H "Authorization: Bearer ct_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'

# Streaming
curl https://api.cleverthis.com/v1/chat/completions \
-H "Authorization: Bearer ct_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}], "stream": true}'

LangChain (Python)

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
model="openai/gpt-4o-mini",
openai_api_key="ct_live_YOUR_KEY",
openai_api_base="https://api.cleverthis.com/v1",
)

result = llm.invoke("Hello, CleverThis!")
print(result.content)
Coming soon

CleverThis-native SDKs (Python and TypeScript) wrapping both the inference API and the A2A management API are being developed.