OpenAI, Anthropic and Gemini SDKs

A base URL and your key. The rest of your code stays.

Checked 2026-10-12

·All guides·Models

Environment variables

Both SDKs read these, so no code changes.

shell
# OpenAI SDK (Python and TypeScript read these)
export OPENAI_BASE_URL="https://api.uplinkswitch.com/v1"
export OPENAI_API_KEY="sk-uplink-live-..."

# Anthropic SDK (Python and TypeScript read these)
export ANTHROPIC_BASE_URL="https://api.uplinkswitch.com/v1"
export ANTHROPIC_API_KEY="sk-uplink-live-..."

Gemini SDK

The base URL goes in http_options.

gemini.py
from google import genai

client = genai.Client(
    api_key="sk-uplink-live-...",
    http_options={"base_url": "https://api.uplinkswitch.com/v1"},
)

Vercel AI SDK

The provider package sets the base URL and reads your key from UPLINKSWITCH_API_KEY. Any model id from the Models page works, with generateText and streamText alike. Source: github.com/uplinkswitch.

shell
npm install ai @uplinkswitch/ai-sdk-provider
ai-sdk.ts
import { createUplinkSwitch } from '@uplinkswitch/ai-sdk-provider';
import { generateText } from 'ai';

const uplinkswitch = createUplinkSwitch(); // reads UPLINKSWITCH_API_KEY

const { text } = await generateText({
  model: uplinkswitch('gpt-6.1-sol'),
  prompt: 'Explain what an API gateway does in one sentence.',
});

Without the package, @ai-sdk/openai-compatible works the same way with the base URL set by hand:

openai-compatible.ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';

const uplinkswitch = createOpenAICompatible({
  name: 'uplinkswitch',
  apiKey: process.env.UPLINKSWITCH_API_KEY,
  baseURL: 'https://api.uplinkswitch.com/v1',
});

const { text } = await generateText({
  model: uplinkswitch('gpt-6.1-sol'),
  prompt: 'Explain what an API gateway does in one sentence.',
});

Streaming

Streams pass through unchanged.

stream.py
from openai import OpenAI

client = OpenAI()  # reads OPENAI_BASE_URL and OPENAI_API_KEY
with client.chat.completions.stream(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "Count to five."}],
) as s:
    for event in s:
        if event.type == "content.delta":
            print(event.delta, end="")

Which format for which model

Every model takes the OpenAI format. The Claude models also take Anthropic's, and the Gemini models Google's. Each model on the Models page lists its own.

API reference

Every route, its request and response shapes and the authentication headers are in the OpenAPI 3.1 document at api.uplinkswitch.com/openapi.json. Model ids and prices come from GET /v1/catalog, which needs no key.