Docs / Migrate from OpenAI

Migrate from OpenAI

Drop-in replacement: three changed lines and a model swap.

Cobble is a drop-in replacement: same API shape, same SDKs, open models on sustainable infrastructure. A typical migration is three changed lines and one model-name swap.

The three lines

python
client = OpenAI(
    base_url="https://api.cobble.network/v1",   # was api.openai.com/v1
    api_key=os.environ["COBBLE_API_KEY"],        # was OPENAI_API_KEY
)
# model="gpt-4o-mini"  →  model="qwen/qwen3.6-27b"

That's the entire code change. Everything else on this page is about choosing models and knowing the behavioral differences.

Model mapping

There's no exact equivalence between proprietary and open models — but there are sensible starting points by job:

If you were usingStart withWhy
GPT-4o / GPT-5.x for reasoning & agentsqwen/qwen3.5-122b-a10bFlagship-class reasoning, 256K context
GPT-4o-mini / small tier for general chatqwen/qwen3.6-27b or gemma4/gemma4-26b-a4bStrong quality at mid-tier cost
The cheapest tier for classification, routing, draftsgemma4/gemma4-e2b or mistral/mistral-nemo-12b130–160 tok/s, pennies per million tokens
A coding modeldeepseek/deepseek-v4-flash1M context, agentic coding specialist
text-embedding-3-smallnomic/nomic-embed-1.5$0.01/1M tokens
text-embedding-3-largeqwen/qwen3-embedding-8b32K context window

Treat these as starting points and A/B your real prompts — open models differ more from each other than proprietary tiers do, and switching between them is a one-string change.

What behaves differently

  • Token counts change. Different models use different tokenizers; the same prompt may be 10–20% more or fewer tokens. If you enforce max_tokens budgets or truncate context by token count, re-measure — don't port hardcoded numbers.
  • Prompts tuned for one model need a pass on another. System prompts with heavy "you are ChatGPT"-era steering often over-constrain open models. Start with your prompt as-is, then simplify.
  • JSON mode and tool calling work, but validate. All catalog generative models support the standard tools and response_format parameters; smaller models are less reliable at complex nested schemas. If structured output matters, test at your target model size.
  • Unsupported OpenAI parameters are ignored, not rejected. Requests won't fail on OpenAI-specific extras, but features like the Assistants API, built-in web search, or proprietary file tooling have no equivalent here — Cobble is the inference layer; orchestration stays in your code or agent framework.
  • No data leaves for model training. Your prompts and outputs are not used to train anything.

Migration checklist

  1. Create a key, set COBBLE_API_KEY, verify with the quickstart curl.
  2. Change base URL and key in one non-critical service.
  3. Pick the mapped model; run your existing eval or a golden-prompt set against it.
  4. Compare cost: your plan window covers steady traffic; spiky overflow bills from the wallet at catalog rates.
  5. Ship, watch error rates for a day, then migrate the rest.

Coming from OpenRouter or another router? Even less changes — your model IDs are likely already in org/model format; check them against /v1/models.