June 11, 2026Big Y

OpenAI-Compatible API Migration: Change Base URL to Flatkey

Move an OpenAI-compatible app to Flatkey: change the base URL, map model IDs, run smoke tests, verify logs, quotas, billing, and rollback.

OpenAI-Compatible API Migration: Change Base URL to Flatkey

If your app already uses an OpenAI compatible API, moving to Flatkey should not start with a rewrite. The controlled path is smaller: get a Flatkey key, point your OpenAI-compatible SDK at https://router.flatkey.ai/v1, choose a model ID from the Flatkey catalog, and verify the first request in logs, quotas, and billing before you send real traffic.

That is the practical value of an OpenAI compatible API. It lets a team keep the same mental model for common requests while moving provider access behind a single gateway. Flatkey's public product copy is built around that motion: one API key, one base URL, clear pricing, unified billing, and one dashboard for keys, usage, and routing.

This guide shows the migration runbook. It covers the base URL change, SDK examples, model ID mapping, smoke tests, endpoint checks, usage-log review, quota setup, billing verification, and rollback. Use it when you are moving an existing Chat Completions-style workflow to Flatkey or standardizing a multi-model stack behind one OpenAI compatible API endpoint.

Quick Answer: What Changes In An OpenAI Compatible API Migration?

For most existing OpenAI-compatible chat clients, the first migration is a configuration change, not an application rewrite.

Setting Before With Flatkey
API key Provider-specific OpenAI, Gemini, DeepSeek, or proxy key Flatkey API key
Base URL Provider default or another OpenAI-compatible base URL https://router.flatkey.ai/v1
Chat endpoint /v1/chat/completions /v1/chat/completions through Flatkey
Model Existing provider model ID Flatkey model ID selected from pricing/dashboard
Validation A successful response only Response + usage log + cost + quota + rollback

The important word is "compatible." An OpenAI compatible API does not guarantee that every provider, model, endpoint, and parameter behaves exactly like OpenAI. It means the API follows enough of the OpenAI request and response pattern for common client calls to work when the base URL, key, and model are correct. Your migration checklist should prove the exact features your app uses.

Why OpenAI-Compatible Endpoints Are Becoming The Migration Layer

The search results for OpenAI compatible API are mostly official references, provider docs, plugins, local server docs, and community questions. That makes sense. Developers are not only asking "what is compatible?" They are trying to move code between model providers without changing every call site.

Google's Gemini docs show OpenAI library examples that set a Gemini OpenAI-compatible base URL and call chat completions. DeepSeek's official API docs show OpenAI SDK examples with DeepSeek's base URL and model IDs such as deepseek-chat and deepseek-reasoner. The pattern is clear: many providers meet developers where their existing SDKs already are.

Flatkey uses the same migration idea for a different goal. Instead of pointing one provider's OpenAI compatible API at one provider account, Flatkey gives teams a single OpenAI-compatible base URL for multi-model access, unified billing, and dashboard visibility.

Step 1: Inventory The Client You Already Have

Before changing the base URL, write down what your current app actually uses. A clean OpenAI compatible API migration starts with the live call shape, not a new sample app.

Check What To Record
SDK Python, Node, direct HTTP, LangChain, LiteLLM, Vercel AI SDK, or another wrapper.
Endpoint Chat Completions, Responses, embeddings, images, video, or provider-native endpoint.
Model ID Exact string used in production and any fallback models.
Message shape System prompts, developer messages, tool messages, multimodal content, or plain text only.
Parameters Streaming, temperature, max tokens, tool calls, JSON output, response format, seed, timeout, retries.
Observability Where you see latency, token usage, request IDs, errors, and cost today.
Rollback How quickly you can restore the old API key/base URL/model.

This inventory keeps the migration honest. If your app only sends simple chat messages, the first Flatkey test can stay small. If your app depends on streaming, tool calls, JSON mode, images, video, or the Responses API, treat each feature as a separate smoke test.

Step 2: Put The Base URL Behind One Config Layer

Do not scatter the new OpenAI-compatible base URL across the codebase. Put it in one environment variable or one SDK factory.

Recommended environment variables:

FLATKEY_API_KEY="sk-fk-your-key"
OPENAI_BASE_URL="https://router.flatkey.ai/v1"
FLATKEY_MODEL="replace-with-publish-day-model-id"
ROLLBACK_OPENAI_BASE_URL="https://api.openai.com/v1"
ROLLBACK_MODEL="your-previous-model-id"

Using OPENAI_BASE_URL is often convenient because many SDK wrappers already support that convention. Using FLATKEY_API_KEY and FLATKEY_MODEL keeps the new credential and model choice explicit.

This is where Flatkey fits the openai compatible base url search intent. The migration should be reviewable in one diff: base URL, key, model, and verification steps.

Step 3: Run A Curl Smoke Test

Start with a direct HTTP request before changing your application. This isolates key, base URL, endpoint, and model ID issues.

Template only: reviewer should run with a valid Flatkey key and confirmed publish-day model ID.

curl -sS "https://router.flatkey.ai/v1/chat/completions" \
  -H "Authorization: Bearer $FLATKEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$FLATKEY_MODEL"'",
    "messages": [
      {
        "role": "user",
        "content": "Reply with one sentence confirming this Flatkey smoke test worked."
      }
    ]
  }'

A useful smoke test proves more than 200 OK. For an OpenAI compatible API migration, check:

  • The response has a usable assistant message.
  • The model name is the one you intended to test.
  • Usage appears in the Flatkey dashboard or usage logs.
  • Token count and cost are visible enough for billing review.
  • Error messages are understandable if the model ID or key is wrong.
  • The old base URL and model can still be restored quickly.

Step 4: Change Python OpenAI SDK Configuration

If your Python app already uses the OpenAI SDK, keep the client construction centralized.

Template only: reviewer should execute before publication.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLATKEY_API_KEY"],
    base_url=os.environ.get("OPENAI_BASE_URL", "https://router.flatkey.ai/v1"),
)

response = client.chat.completions.create(
    model=os.environ["FLATKEY_MODEL"],
    messages=[
        {
            "role": "user",
            "content": "Confirm this OpenAI compatible API request is routed through Flatkey.",
        }
    ],
)

print(response.choices[0].message.content)
print(response.usage)

The Python detail that matters is base_url. In a clean OpenAI compatible API migration, application code should not know whether the base URL points directly to OpenAI, a provider-compatible endpoint, or Flatkey. It should call the shared client and let configuration choose the route.

Step 5: Change Node OpenAI SDK Configuration

For Node apps, the equivalent configuration uses baseURL.

Template only: reviewer should execute before publication.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FLATKEY_API_KEY,
  baseURL: process.env.OPENAI_BASE_URL || "https://router.flatkey.ai/v1",
});

const response = await client.chat.completions.create({
  model: process.env.FLATKEY_MODEL,
  messages: [
    {
      role: "user",
      content: "Confirm this OpenAI compatible API request is routed through Flatkey.",
    },
  ],
});

console.log(response.choices[0].message.content);
console.log(response.usage);

This is the same migration pattern seen across provider docs: keep the SDK, set a different base URL, supply a compatible API key, and choose a model ID that exists on the target platform.

Step 6: Map Model IDs Deliberately

The model string is where many OpenAI compatible API migrations fail. A base URL can be compatible while model IDs remain provider-specific.

Do not assume:

  • Your old model name exists in Flatkey.
  • A provider's model alias points to the same version behind a gateway.
  • Every compatible model supports the same endpoint family.
  • A model that works for chat also works for vision, tools, images, video, or Responses.

Instead, use this mapping table before the first app-level test:

Current App Use Flatkey Check
Text chat Choose a Flatkey model that supports the OpenAI chat endpoint.
Streaming chat Test streaming separately with the same prompt and timeout budget.
Tool/function calling Verify the selected model and endpoint support the tool-call shape your app sends.
JSON output Test your exact response_format or structured-output pattern.
Vision/image input Confirm the selected model accepts the image input format your SDK sends.
Responses API Confirm the Flatkey endpoint/model supports /v1/responses for your use case.
Image or video generation Treat it as a separate endpoint migration, not a chat-completions migration.

Flatkey's pricing snapshot on June 11, 2026 showed endpoint families for OpenAI chat completions, OpenAI Responses, Anthropic messages, Gemini, image generation, and OpenAI video. That is useful reviewer proof, but the article should still push readers to confirm the exact model and feature they plan to use on publish day.

Step 7: Verify Logs, Quotas, And Billing

A successful OpenAI compatible API response is only the first checkpoint. The reason to migrate through Flatkey is not just the request shape; it is the operating surface around model access.

After the smoke test, verify:

Area What To Inspect
Usage log Request appears with timestamp, model, token usage, status, and error details if any.
Billing Cost is visible and matches the expected model/pricing unit.
Quota A small quota can be set for the new key or test route before broader rollout.
Routing The request is routed through the intended Flatkey path, not a stale direct-provider config.
Error behavior Bad key, bad model, and unsupported-parameter errors are clear enough for support.
Rollback Restoring the previous base URL/model works without code changes.

This is where an OpenAI compatible API gateway becomes more useful than a raw provider endpoint. The base URL change should lead to better visibility, not just a different upstream.

Step 8: Roll Out In Stages

Do not move every workflow at once. Use a staged rollout:

  1. Run a direct curl smoke test.
  2. Run one SDK smoke test in local or staging.
  3. Replay a small known prompt set and compare output shape.
  4. Enable streaming or advanced parameters only after the basic call passes.
  5. Put a low quota on the test key.
  6. Send a small percentage of non-critical traffic.
  7. Compare errors, latency, token usage, and cost.
  8. Increase traffic only after logs and billing match expectations.

This flow keeps the OpenAI compatible API promise tied to production reality. Compatibility is not a slogan; it is a test result for the calls your app actually sends.

Migration Checklist

Use this as the publish-page asset.

Step Done? Notes
Current SDK and endpoint are documented Python, Node, HTTP, wrapper, chat, responses, image, video, etc.
Flatkey key is created Use a separate test key where possible.
Base URL is centralized https://router.flatkey.ai/v1 should live in config, not scattered code.
Model ID is selected from Flatkey Confirm publish-day model ID from pricing or dashboard.
Curl smoke test passes Template must be reviewer-tested before publish.
Python or Node SDK smoke test passes Use the SDK your app actually runs.
Streaming/tool/JSON/vision features are tested Test only the features you use.
Usage log is visible Confirm model, status, tokens, and errors in the dashboard.
Billing and pricing unit are reviewed Do not assume provider pricing units are identical.
Quota limit is set Keep migration traffic bounded.
Rollback env vars are ready Old base URL and model can be restored without code changes.

Common Mistakes

The most common OpenAI compatible API migration mistake is changing the base URL and assuming every other detail is identical. Avoid these traps:

  • Hardcoding the Flatkey base URL in multiple files.
  • Keeping an old provider model ID that Flatkey does not route.
  • Testing only non-streaming when production uses streaming.
  • Skipping tool-call or JSON-output tests.
  • Moving image/video endpoints as if they were chat-completions endpoints.
  • Forgetting to update retries, timeout budgets, and error parsing.
  • Calling the migration done before usage and billing are visible.

Flatkey reduces provider-account and routing sprawl, but it does not remove the need for a careful migration test.

When Flatkey Is A Good Fit

Flatkey is a strong fit when your team wants one OpenAI compatible API base URL for multi-model access instead of separate provider accounts, keys, billing, and routing checks.

Use Flatkey when:

  • Your app already uses an OpenAI-compatible SDK.
  • You want one key for models across providers such as GPT, Claude, Gemini, DeepSeek, Qwen, Seedance 2.0, and GPT Image.
  • You want usage, billing, keys, and routing visible in one dashboard.
  • You want quota limits before traffic ramps up.
  • You want model switching and load-balancing behavior handled by the gateway layer.
  • You want the migration path to be "change base URL, verify model, monitor usage" instead of "rewrite the model integration."

Use a direct provider account or a self-hosted proxy when you need provider-specific contracts, fully custom routing logic, or infrastructure-local gateway control.

FAQ

Is an OpenAI compatible API the same as OpenAI?

No. An OpenAI compatible API follows the OpenAI-style request and response pattern for supported endpoints, but the provider, model IDs, authentication, feature support, pricing, and error behavior can differ.

Do I need to replace my SDK to use Flatkey?

Usually no for common chat-completions migrations. If your SDK supports a custom base URL, you can often keep the SDK and change configuration. That is the core appeal of an OpenAI compatible API migration.

What is the Flatkey OpenAI-compatible base URL?

Use https://router.flatkey.ai/v1 as the OpenAI-compatible base URL. For chat completions, the full endpoint is https://router.flatkey.ai/v1/chat/completions.

Can I keep my existing model name?

Only if that model ID is available and supported through Flatkey. Check pricing or the dashboard, then test the exact model ID before rollout.

Should I migrate Chat Completions or Responses first?

Migrate the endpoint your existing app uses. Existing Chat Completions apps can start with /v1/chat/completions. If your app uses the Responses API, test /v1/responses separately and confirm the selected model supports the features you need.

How do I roll back?

Keep the old base URL, API key, and model in configuration until Flatkey logs, cost, quota, and application behavior are verified. Rollback should be an environment-variable change, not a code rewrite.

Get A Key

If you already have an app built around an OpenAI compatible API, Flatkey keeps the migration small: get a key, change the base URL, choose a model, run the smoke test, and monitor usage in one dashboard.

Get a key, then use https://router.flatkey.ai/v1 as the base URL for your first Flatkey migration test.

OpenAI-Compatible API Migration: Change Base URL to Flatkey | flatkey.ai