Skip to content
Getting startedLLM

One API Key for GPT, Claude and Gemini: A Practical Setup Guide

A team can start with one GPT integration and soon find itself maintaining separate credentials, clients, and billing workflows for Claude and Gemini.

By the Openrouter API team9 min read
One API Key for GPT, Claude and Gemini: A Practical Setup Guide

A team can start with one GPT integration and soon find itself maintaining separate credentials, clients, and billing workflows for Claude and Gemini. Openrouter API brings those models behind one API key and an OpenAI-compatible base URL, so you can compare them without rebuilding your application around each provider. This guide covers setup, shared-client calls, native API options, pricing, and the operational safeguards worth adding before production.

Why teams end up with three keys and three invoices

Different tasks lead teams toward different model families. One application might use GPT for general assistance, Claude for complex document work, and Gemini for another workflow that performs well in its own evaluations.

With separate provider integrations, that choice also introduces operational work: credentials to distribute, billing accounts to monitor, client libraries to maintain, and error handling to reconcile. None of those tasks directly improves the application’s answers.

Openrouter API provides one gateway for 250+ chat, image, video, and audio models. For the text workflows in this guide, the common connection details are:

  • Base URL: https://openrouterapi.ru/v1
  • Authentication: Authorization: Bearer <OPENROUTERAPI_API_KEY>
  • Shared chat endpoint: POST /v1/chat/completions
  • Model discovery: GET /v1/models

The practical benefit is a smaller integration surface. Your application can keep the same client and change the model ID.

That does not make the models interchangeable. Outputs, supported features, and task suitability still need testing. Treat the gateway as a way to simplify access, not as a reason to skip model-specific evaluation.

Step 1: Create an account and fund it

Create an Openrouter API account, then top up your balance. The minimum top-up is $50.

Openrouter API uses pay-as-you-go billing in USD. Only successful requests are billed, and credits never expire. You can therefore fund an initial evaluation without committing to a recurring subscription.

Before making calls, review the current pricing and the relevant model pages. For a useful first evaluation, choose a small set of representative inputs rather than sending production traffic immediately:

  • A short classification request.
  • A typical user-facing question.
  • A difficult reasoning or synthesis task.
  • A longer input representative of your application.

Save those inputs as a repeatable test set. When you later change models or routing rules, rerun the same cases and compare results.

One billing distinction matters operationally: a request that succeeds but produces an answer your application rejects is still a successful request. Application-level retries and fallback calls can therefore add spend even when the first answer was not useful.

Step 2: Create a key and store it outside your code

Create an Openrouter API key in your account. Store it in an environment variable on the machine or server that will make requests.

For a local shell, the setup looks like this:

bash
export OPENROUTERAPI_API_KEY="replace-with-your-api-key"
export OPENAI_BASE_URL="https://openrouterapi.ru/v1"

Do not commit the actual value to source control. If you use a local environment file, exclude it from version control and provide a separate example file containing only variable names and placeholders.

In deployment, prefer your platform’s secret manager or protected environment-variable configuration. The important boundary is that the key belongs on the server, not in the browser.

A browser application should call your backend. Your backend should authenticate the user, enforce application limits, and then call Openrouter API. Putting a shared gateway key in frontend JavaScript exposes it to anyone who can inspect the application.

Check connectivity before adding application logic

A model-list request is a simple way to verify your environment variable and connection:

bash
curl https://openrouterapi.ru/v1/models \
  -H "Authorization: Bearer $OPENROUTERAPI_API_KEY"

Use the returned model list to check available IDs rather than deriving them from marketing names. The identifiers in this guide are exact strings, including suffixes such as -preview.

For broader integration details, keep the Openrouter API docs alongside your application’s setup notes. Future maintainers should be able to find the base URL, credential source, and selected models without reverse-engineering the code.

Step 3: Make a first chat request

The shared chat interface is POST /v1/chat/completions. Start with a small request so that authentication and request formatting are easy to inspect.

bash
curl https://openrouterapi.ru/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {
        "role": "user",
        "content": "Explain why an API key should stay on the server in two sentences."
      }
    ]
  }'

This uses gpt-5.4-mini, the lower-priced OpenAI option in the supplied comparison. It is a sensible starting point for testing the integration, but price alone does not establish whether it is suitable for your production task.

Keep the first request deliberately ordinary. Adding tools, complex output requirements, or large documents before the basic connection works makes troubleshooting harder.

Once this succeeds, move the same connection settings into your application client.

Step 4: Call GPT, Claude, and Gemini with one client

Install the official OpenAI Python SDK in your application environment. Configure it with the Openrouter API key and base URL rather than separate credentials for each model family.

The following example runs the same prompt through one model from each family:

python
import os

from openai import OpenAI

# Read the same key exported as $OPENROUTERAPI_API_KEY in your shell.
client = OpenAI(
    api_key=os.environ["OPENROUTERAPI_API_KEY"],
    base_url="https://openrouterapi.ru/v1",
)

models = [
    "gpt-5.4-mini",
    "claude-haiku-4-5",
    "gemini-3.5-flash",
]

prompt = (
    "Classify this support request as billing, technical, or account: "
    "'I cannot sign in after changing my email address.' "
    "Return only the category."
)

for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}],
    )

    print(f"{model}: {response.choices[0].message.content}")

The client, credential, endpoint, and message structure stay the same. The model ID changes.

This is useful for evaluation, but it is not the routing pattern you should automatically deploy. Calling all three models for every request creates three separate model calls where one might suffice.

In production, choose a model before sending the request. Reserve parallel comparisons for deliberate experiments, sampled evaluations, or workflows that genuinely require multiple outputs.

Keep connection settings separate from routing policy

Avoid scattering model IDs throughout your codebase. Put them in application configuration or a small routing module.

That gives you two separate concerns:

  1. Connection configuration: API key and Openrouter API base URL.
  2. Task policy: Which model handles a given kind of request.

A model change should not require rewriting authentication code. Likewise, rotating a key should not require changing your classification policy.

Keep the selected model in your application logs, along with a request identifier and outcome. Do not log the key. Avoid recording sensitive prompt content unless your data-handling policy explicitly allows it.

Compare flagship and lower-priced models

The table below includes a flagship and a lower-priced option for each family, plus Claude Sonnet as an additional price point. “Lower-priced” is relative to the flagship in the same family; it does not imply equivalent quality or capabilities.

All token prices are in USD. Each price cell includes its unit, and the final column is the supplied maximum input, not a claim about available output length.

FamilyModelPosition in this comparisonInput priceOutput priceCached input priceMax input
OpenAIgpt-5.5Flagship$4.40 per 1M tokens$26.40 per 1M tokens$0.44 per 1M tokens922,000 tokens
OpenAIgpt-5.4-miniLower-priced option$0.66 per 1M tokens$3.96 per 1M tokens$0.066 per 1M tokens272,000 tokens
Anthropicclaude-opus-4-8Flagship$4.40 per 1M tokens$22.00 per 1M tokens$0.44 per 1M tokens1,000,000 tokens
Anthropicclaude-sonnet-4-6Additional option$2.64 per 1M tokens$13.20 per 1M tokens$0.264 per 1M tokens1,000,000 tokens
Anthropicclaude-haiku-4-5Lower-priced option$0.88 per 1M tokens$4.40 per 1M tokens$0.088 per 1M tokens200,000 tokens
Googlegemini-3.1-pro-previewFlagship$1.76 per 1M tokens$10.56 per 1M tokens$0.176 per 1M tokens1,048,576 tokens
Googlegemini-3.5-flashLower-priced option$1.32 per 1M tokens$7.92 per 1M tokens$0.132 per 1M tokens1,048,576 tokens

For cost planning, estimate input and output separately. A long-document workflow and a short-prompt workflow with verbose answers can have very different cost profiles.

Do not assume that all repeated input receives the cached-input price. Check the applicable caching behavior in the docs and model documentation before including cache savings in a budget.

Similarly, maximum input capacity is not a recommendation to fill the entire limit. Send the context needed for the task, remove irrelevant material, and measure whether additional context improves the result.

When to use native API formats

The shared chat endpoint is the simplest starting point when your goal is switching between model families. Native formats are useful when an existing application already depends on a provider-specific protocol.

InterfaceEndpointPractical reason to choose it
Shared chatPOST /v1/chat/completionsUse one OpenAI-compatible client across GPT, Claude, and Gemini
Claude MessagesPOST /v1/messagesPreserve an Anthropic Messages integration
Gemini nativePOST /v1beta/models/{model}:generateContentPreserve Gemini-native request formatting
OpenAI ResponsesPOST /v1/responsesUse a Responses-based integration

An endpoint choice is not a guarantee that every feature behaves identically across models. Validate the specific request fields and response behavior your application needs.

Claude: Anthropic SDK configuration

Openrouter API’s listed Claude models are fully compatible with the native Anthropic Claude Messages protocol at POST /v1/messages. That endpoint also accepts Anthropic-style x-api-key authentication.

For an Anthropic SDK integration, configure the gateway origin:

python
import os

from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["OPENROUTERAPI_API_KEY"],
    base_url="https://openrouterapi.ru",
)

This differs from the OpenAI SDK configuration: the Anthropic SDK uses its /v1/messages resource path, so the configured base is the origin rather than the OpenAI-compatible /v1 base.

Use the docs to check the native Messages request requirements before adapting an existing call.

Gemini: native generateContent

For Gemini-native requests, use the gateway origin with /v1beta/models/{model}:generateContent. For example, the model-specific path for the listed flagship is /v1beta/models/gemini-3.1-pro-preview:generateContent.

Do not append that path to https://openrouterapi.ru/v1; it belongs under the origin’s /v1beta route. Retain the same Openrouter API credential and verify the native payload against the documentation.

OpenAI: Responses

For a Responses-based application, use POST /v1/responses. Keep the Openrouter API base URL and key, then follow the documented Responses request format.

Do not treat a Chat Completions request body as interchangeable with a Responses body. Choose the interface intentionally and test the behavior your application relies on.

Build routing around tasks, not brand preference

A useful initial routing policy has three parts: a lower-cost default for simple work, a flagship route for difficult work, and an explicit fallback list.

Use a lower-priced model for classification

For constrained tasks such as support-ticket categorization, evaluate gpt-5.4-mini, claude-haiku-4-5, and gemini-3.5-flash.

Define the allowed labels and validate the returned value in application code. If the answer falls outside that set, treat it as a failed application result rather than passing it downstream unchecked.

Choose the default using your test cases and acceptable error rate, not price alone.

Escalate hard reasoning deliberately

Evaluate gpt-5.5, claude-opus-4-8, and gemini-3.1-pro-preview for tasks where incorrect reasoning is costly or the input requires substantial synthesis.

Use task characteristics or validation failures to trigger escalation. Avoid relying solely on a model’s self-reported confidence.

Keep human review where the consequences warrant it. A more expensive model is not a correctness guarantee.

Make fallback lists explicit and bounded

A candidate classification fallback order could be gpt-5.4-mini, then claude-haiku-4-5, then gemini-3.5-flash. That is a configuration example, not a performance ranking.

Separate temporary request failures from invalid inputs and application-level validation failures. Retrying an unchanged invalid request is unlikely to help. A fallback answer also needs the same validation as the original.

Set a maximum number of attempts, and log which route succeeded. A fallback can restore availability while quietly changing answer behavior, so include fallback cases in your evaluations.

Keep the shared key manageable in production

“One API key” means one credential can access multiple model families. It should not mean one secret copied into every environment.

Create separate keys for development, staging, and production. That makes accidental exposure easier to contain and avoids rotating production credentials because a developer’s local setup was compromised.

Rotate keys through a controlled deployment process: update the secret, verify requests with the replacement, and revoke the old key once the transition is complete. If a key is exposed, revoke it promptly rather than waiting for a scheduled rotation.

Finally, monitor application spend and request volume. Centralizing access simplifies billing, but your backend still needs user authentication, bounded retries, and safeguards against accidental request loops.

Key takeaways

  • Use https://openrouterapi.ru/v1 and one Openrouter API key for shared GPT, Claude, and Gemini chat calls.
  • Keep native Messages, Gemini, or Responses formats when your integration needs them.
  • Route simple work to an evaluated lower-priced model and escalate difficult tasks deliberately.
  • Validate fallback outputs, bound retries, and keep credentials server-side and environment-specific.

Create an account at Openrouter API and top up from $50 to test your first shared-client workflow.

Models in this article

More articles

All articles
Depth: 250+ models · Minimum top-up $50

One key. Every model. Start shipping today.

Create an account, top up from $50, and point your existing OpenAI, Anthropic or Gemini SDK at Openrouter API. No subscriptions, no seat fees, no idle charges.