One API Key for Claude, GPT, Gemini and DeepSeek

Call Claude, GPT, Gemini and DeepSeek with one prepaid key and one request format. Switch models with one string, add a fallback, and compare cost per request.

3 min read

claudegptgeminideepseektutorial

One golden key at the centre of four glowing doors, each slightly open

Most teams end up using more than one AI model: a cheap one for simple jobs, a strong one for hard ones, and a second maker in case the first has a bad day. Doing that directly means an account, a key, an SDK and a bill for each maker. Through API Store it is one key, one balance and one request format. This post shows what that looks like in code.

One request format

Every chat model on API Store takes the OpenAI Chat Completions request and answers in the same shape, whoever made it. So this function works for all of them:

python
from openai import OpenAI

client = OpenAI(base_url="https://api.apistore.cloud/v1", api_key="sk-...")

def ask(model, prompt):
    reply = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}],
    )
    return reply.choices[0].message.content, reply.usage

for model in ["claude-sonnet-5-5", "gpt-6.2-sol", "gemini-3.8-flash", "deepseek-v4-1-flash"]:
    text, usage = ask(model, "Explain idempotency keys in one paragraph.")
    print(model, usage.prompt_tokens, usage.completion_tokens)
    print(text, "\n")

Streaming, tools and reasoning_effort are written the same way for every model, and so are images in image_url parts for the models that read them (Claude, GPT and Gemini). The gateway turns them into whatever the maker's own API expects.

Model names

The model name is the only thing that changes. Some to start with:

MakerEverydayStrongestLowest price
Anthropicclaude-sonnet-5-5claude-fable-5-1claude-haiku-5-5
OpenAIgpt-6.2-solgpt-6.2-astragpt-6-luna
Googlegemini-3.8-flashgemini-4-neongemini-3.1-flash-lite
DeepSeekdeepseek-v4-1-flashdeepseek-v4-1-flashdeepseek-v4-1-flash-economy

The full list with prices is on the pricing page and under Models. Your code can also read it from GET /v1/models with your key.

A fallback in a few lines

If one maker is slow or refuses a request, you can try the next one:

python
CHAIN = ["claude-sonnet-5-5", "gpt-6.2-sol", "gemini-3.8-flash"]

def ask_any(prompt):
    last = None
    for model in CHAIN:
        try:
            return ask(model, prompt)
        except Exception as err:   # e.g. openai.APIStatusError
            last = err
    raise last

Only move on for errors that another model can fix: 429, 5xx and timeouts. A 400 or 401 will fail on every model, so raise it straight away. AI API errors and retries has the full list. A request that fails is not charged.

Compare cost on your own prompts

Prices per million tokens don't tell the whole story. Models count tokens differently, and some write much longer answers than others. The fair test is your own prompts:

  1. Send the same twenty inputs to each model you're considering.
  2. Open the Usage page. It shows the tokens and the cost of every request, by model.
  3. Weigh the cost against the answers you got.

Thinking models also spend output tokens on reasoning, so compare with the reasoning_effort you'll use in production.

One balance, one set of limits

  • One prepaid balance pays for every model. There is no subscription and no monthly minimum.
  • Keys per app. Create a key for each app or environment and give each a daily spending cap on the API keys page. The cap covers all models on that key.
  • IP allowlists on a key work the same whatever model it calls. See securing your keys.

Read more

Also in Tiếng Việt, Español, Português, Bahasa Indonesia