Tool setup
Any OpenAI-compatible tool
The generic recipe for any SDK or client that speaks the OpenAI API.
Anything that speaks the OpenAI API — the official SDKs, LangChain, LlamaIndex, Aider, Continue, your own scripts — works with the gateway. This is the generic recipe.
What you get
- Any OpenAI-compatible client pointed at the gateway, billed to your project's sponsor budget, with no code changes beyond the base URL and key.
Prerequisites
- Your project access key and base URL from your
project control panel —
YOUR_PROJECT_KEYandhttps://v1.opentokenmarket.dev.
The two values
| Setting | Value |
|---|---|
| Base URL (OpenAI-style clients) | https://v1.opentokenmarket.dev |
| Base URL (Anthropic-style clients) | https://v1.opentokenmarket.dev |
| API key / bearer token | YOUR_PROJECT_KEY |
| Model | any Model name from the model catalog |
Most tools read these from OPENAI_BASE_URL and OPENAI_API_KEY:
export OPENAI_BASE_URL="https://v1.opentokenmarket.dev"
export OPENAI_API_KEY="YOUR_PROJECT_KEY"
Examples
OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
base_url="https://v1.opentokenmarket.dev",
api_key="YOUR_PROJECT_KEY",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Say hi in 3 words."}],
)
print(resp.choices[0].message.content)
OpenAI SDK (Node)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://v1.opentokenmarket.dev",
apiKey: process.env.OPENAI_API_KEY,
});
const resp = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Say hi in 3 words." }],
});
console.log(resp.choices[0].message.content);
cURL
curl https://v1.opentokenmarket.dev/chat/completions \
-H "Authorization: Bearer YOUR_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"ping"}]}'
Anthropic-style clients
The gateway also serves the Anthropic Messages API. Point ANTHROPIC_BASE_URL at
https://v1.opentokenmarket.dev (no /v1) and send the key as x-api-key or ANTHROPIC_AUTH_TOKEN.
See the Claude Code guide for a worked example.
Troubleshooting
404on/chat/completions— your base URL is missing the trailing/v1.401— the key isn't your project access key, or it's sent in the wrong header. UseAuthorization: Bearer <key>for OpenAI-style,x-api-key: <key>for Anthropic-style.model not found— use an exact name from the model catalog.budget has been exceeded— the project's funded balance is spent. Ask your sponsor to top up.
List models programmatically
curl https://v1.opentokenmarket.dev/models -H "Authorization: Bearer YOUR_PROJECT_KEY"