OpenAI Compatible API

Use the standard OpenAI SDK to access GPT-4o, Claude, DeepSeek, and GLM models through a single endpoint. 100% API compatible - change only base_url. No vendor lock-in, no SDK changes, no code rewrites.

Get API Access

What Makes an API "OpenAI Compatible"?

An OpenAI-compatible API implements the exact same REST API specification as OpenAI's official API. This means:

Why this matters: If your code works with OpenAI, it works with Token1.US. You keep using the same SDK, same tutorials, same Stack Overflow answers. You just get access to more models at lower prices.

Quick Migration: 2 Lines Changed

Before (OpenAI Direct)

from openai import OpenAI

client = OpenAI(
    api_key="sk-openai-key",
    base_url="https://api.openai.com/v1"  # OpenAI direct
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

After (Token1.US)

from openai import OpenAI

client = OpenAI(
    api_key="sk-token1-key",
    base_url="https://discount-token.com/v1"  # Changed!
)

response = client.chat.completions.create(
    model="gpt-4o",  # Same model name
    messages=[{"role": "user", "content": "Hello!"}]
)

# OR switch to a cheaper model with zero code changes:
# model="deepseek-chat"  # 94% cheaper
# model="claude-3-5-sonnet"  # Different provider
# model="glm-4-plus"  # Bilingual tasks

Supported API Features

FeatureOpenAI APIToken1.USNotes
Chat CompletionsYesYesIdentical format
Streaming (SSE)YesYesToken-by-token output
Function CallingYesYesTools/functions parameter
Vision (Image Input)YesYesGPT-4o, Claude models
JSON ModeYesYesStructured output
LogprobsYesYesToken probabilities
Multiple CompletionsYesYesn parameter
Seed ParameterYesYesReproducible outputs
Multi-model accessGPT onlyAll modelsGPT + Claude + DeepSeek + GLM

Framework Integration

LangChain

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-chat",
    api_key="sk-token1-key",
    base_url="https://discount-token.com/v1"
)

response = llm.invoke("What is the capital of France?")

JavaScript / Node.js

import OpenAI from 'openai';

const client = new OpenAI({
    apiKey: 'sk-token1-key',
    baseURL: 'https://discount-token.com/v1'
});

const response = await client.chat.completions.create({
    model: 'claude-3-5-sonnet',
    messages: [{ role: 'user', content: 'Hello!' }]
});

cURL

curl https://discount-token.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-key" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

LlamaIndex

from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="deepseek-chat",
    api_key="sk-token1-key",
    base_url="https://discount-token.com/v1"
)

Available Models Through OpenAI-Compatible Endpoint

OpenAI Models

Anthropic Models

DeepSeek Models

Zhipu GLM Models

Why Use an OpenAI-Compatible Gateway?

1. No Vendor Lock-In

Your code is not tied to any single AI provider. Switch between GPT, Claude, DeepSeek, and GLM by changing one parameter. If a provider has an outage, failover to another instantly.

2. Cost Optimization

Route simple tasks to budget models (DeepSeek-V3 at $0.14/1M) and reserve expensive models (GPT-4o) for complex tasks. Typical savings: 70-85%.

3. Unified Billing

One account, one API key, one invoice. No need to manage separate accounts with OpenAI, Anthropic, DeepSeek, and Zhipu AI.

4. Consistent Interface

All models use the same API format. Your team only needs to learn one API. Documentation, error handling, and SDK code work across all models.

Migration Checklist

  1. Sign up at Token1.US and generate an API key
  2. Add credits ($1 minimum for paid models, free for GLM-4-Flash)
  3. Update base_url in your application configuration
  4. Replace API key with your Token1.US key
  5. Test with a simple request
  6. Optionally switch model names for cost optimization
  7. Set up error handling and monitoring
  8. Update environment variables in production
Pro tip: Use environment variables for base_url and api_key so you can switch between OpenAI direct and Token1.US without code changes: BASE_URL=https://discount-token.com/v1

Frequently Asked Questions

Are there any differences in API behavior?

No. The request and response formats are identical to OpenAI's API. Parameters like temperature, max_tokens, top_p, frequency_penalty, and presence_penalty all work the same way. Streaming responses use the same SSE format.

Can I use this with existing OpenAI tutorials and documentation?

Yes. Any tutorial, course, or documentation that uses the OpenAI API works with Token1.US. Simply replace the base_url and API key. The OpenAI Python and JavaScript SDK documentation applies directly.

What happens if a model provider has an outage?

Token1.US routes requests to the appropriate provider. If one provider is down, you can instantly switch to another model by changing the model parameter. For example, switch from gpt-4o to claude-3-5-sonnet for immediate fallback.

Is the response speed the same as calling OpenAI directly?

Token1.US adds minimal latency (typically <50ms) through its global CDN. For most use cases, the difference is imperceptible. Streaming time-to-first-token is typically 200-500ms, comparable to direct API access.

Start Using OpenAI-Compatible API