Skip to main content
This guide shows you how to point the official OpenAI SDK at the to11 gateway. Set the base_url to the gateway, authenticate to to11 with the x-to11-authorization header, and keep passing your provider key as the SDK’s api_key — the rest of your code stays the same.

Python

Install the SDK if you haven’t already:
Set the base_url to your gateway:

TypeScript / Node.js

Streaming

Add stream: true to receive the response incrementally. The gateway streams chunks back as they arrive from the provider, and the call is traced the same as a non-streaming one.

Cross-format routing

You can route OpenAI-format requests to Anthropic models. The gateway translates the request and returns the response in OpenAI format — your code doesn’t change:
System messages are automatically extracted and forwarded as Anthropic’s top-level system field. Tool definitions are translated between formats.

Tool calling

Tool calling works identically to direct OpenAI usage:
If this request is routed to an Anthropic model, the gateway translates tool definitions to Anthropic’s input_schema format automatically.

Environment variable configuration

If you prefer not to hard-code the base URL, use the OPENAI_BASE_URL environment variable: