OpenAI / Anthropic Compatibility
The gateway speaks both wire protocols natively with the same sk- key as
a Bearer token. Exact request and response shapes for every endpoint are
in the agent reference - this page only covers SDK setup.
OpenAI SDK
Change only the base URL:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-xxxx',
baseURL: 'https://tokpum.com/v1',
});
const res = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello' }],
});
Streaming: pass stream: true and consume chunks exactly as with OpenAI -
see the SSE streaming pattern.
Anthropic SDK
The gateway does NOT accept the Anthropic SDK's default x-api-key
header. Keep the official base URL style but pass the key as a Bearer
token:
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: 'sk-xxxx',
baseURL: 'https://tokpum.com',
defaultHeaders: { Authorization: 'Bearer sk-xxxx' },
});
const res = await client.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 100,
messages: [{ role: 'user', content: 'Hello' }],
});
Endpoint surfaces
OpenAI-compatible (base https://tokpum.com/v1):
- POST /v1/chat/completions - chat, tools, streaming
- POST /v1/responses - OpenAI Responses API
- POST /v1/images/generations - text to image
- POST /v1/images/edits - image edit
- GET /v1/models - model list for your key
Anthropic-compatible (base https://tokpum.com):
- POST /v1/messages - chat, tools, streaming
Video (async task API, OpenAI-style auth):
- POST /v1/video/generations - submit
- GET /v1/video/tasks/{task_id} - poll
- POST /v1/video/tasks/{task_id}/cancel - cancel
- Working with long tasks: async video pattern
Agent tooling: POST /mcp - MCP server for self-onboarding and account management; see Agent Onboarding (MCP).
Plain HTTP
No SDK required. Every endpoint is a plain POST with a JSON body and an
Authorization: Bearer sk-xxxx header - curl examples for each are in the
reference pages above.