How to Use GPT, Claude and Gemini With One API Key (Step-by-Step Guide)
If you build anything with AI, you have probably noticed that no single model is best at everything. One model writes better code, another is faster for short answers, another is much cheaper for simple tasks, and some are the only option for voice or images.
The problem is that each provider wants its own account, its own API key and its own billing. Before long you are juggling four dashboards and four invoices just to test which model works best for your project.

The good news is that you don’t have to. In this guide, you will learn how to use GPT, Claude, Gemini, DeepSeek and other models through one API key, how to switch between them in a single line of code, and how to connect the same key to popular tools.
What you need
- A computer with Python 3.8+ installed (or Node.js if you prefer JavaScript)
- A code editor such as VS Code
- An account with a unified AI API provider
- About 15 minutes
What is a unified AI API?
A unified AI API is a service that sits between your app and the AI providers. You send every request to one endpoint with one key, and simply change the model name to pick which AI answers. The service forwards your request to the right provider and returns the response in a standard format.
Most unified APIs use the same request format as OpenAI. That is important, because it means almost any tool or library that works with OpenAI also works with them. You only change two things: the base URL and the API key.
Step 1: Create an account and get your API key
For this guide we will use Oxyy, which gives access to more than 178 AI models, including models from OpenAI, Anthropic, Google, DeepSeek and xAI, plus voice and image models, under one balance. It is pay-per-use, so there is no monthly subscription. Other unified APIs work in a very similar way.
- Sign up on the website.
- Open the dashboard and go to API Keys.
- Click Create key and give it a name, for example “test-project”.
- Copy the key and store it somewhere safe. Most dashboards only show it once.
Tip: never paste API keys directly into your code or share them in screenshots. Store them in an environment variable instead.
Step 2: Save the key as an environment variable
On Windows (PowerShell):
$env:OXYY_API_KEY = “your-key-here”
On Mac or Linux:
export OXYY_API_KEY=”your-key-here”
To make it permanent on Mac or Linux, add that line to your ~/.zshrc or ~/.bashrc file.
Step 3: Install the OpenAI library
Because the API is OpenAI-compatible, you can use the official OpenAI Python library:
pip install openai
Step 4: Send your first request
Create a file called ask.py and paste this code:
import os
from openai import OpenAI
client = OpenAI(
base_url=”https://api.oxyy.ai/v1″,
api_key=os.environ[“OXYY_API_KEY”],
)
response = client.chat.completions.create(
model=”claude-sonnet-5″,
messages=[{“role”: “user”, “content”: “Explain what an API is in two sentences.”}],
)
print(response.choices[0].message.content)
Run it with:
python ask.py
You should see a short answer printed in your terminal. That’s it: you just called Claude using the standard OpenAI library.
Step 5: Switch models with one line
Now change the model value and run the script again. For example:
- claude-sonnet-5 for strong reasoning and writing
- gemini-3.1-pro for long documents
- deepseek-v4-pro for low-cost coding and general tasks
- grok-4.7 for quick answers
Nothing else in your code needs to change. You can even loop over several models to compare their answers side by side:
for model in [“claude-sonnet-5”, “deepseek-v4-pro”, “grok-4.7”]:
r = client.chat.completions.create(
model=model,
messages=[{“role”: “user”, “content”: “What is the fastest way to reverse a string in Python?”}],
)
print(model, “->”, r.choices[0].message.content)
This is the easiest way to find the best model for your task. Try your real prompts on three or four models and keep the one that gives good results at the lowest cost.
Step 6: Use the same key in your favourite tools
Since the API follows the OpenAI format, you can use it in many apps without writing any code:
- VS Code extensions (Cline, Roo Code, Continue): choose “OpenAI Compatible” as the provider, set the base URL to https://api.oxyy.ai/v1, paste your key and type the model name.
- n8n: in the OpenAI node, add a credential with your key and change the base URL.
- Open WebUI or LibreChat: add a new OpenAI-compatible connection with the same base URL and key.
- Claude Code: set ANTHROPIC_BASE_URL to https://api.oxyy.ai, put your key in ANTHROPIC_AUTH_TOKEN, and leave ANTHROPIC_API_KEY empty. This works with the Claude models.
Tips to keep your AI costs low
- Use smaller models for simple jobs. Summaries, tagging and short replies rarely need a top-tier model.
- Keep prompts short. Every word you send is billed, including long system prompts and chat history.
- Start a new conversation for a new task instead of continuing a very long one.
- Create a separate key per project so you can see exactly where your money goes.
- Check the usage page regularly to spot anything unusual early.
Common problems and fixes
- “Invalid API key” error: make sure the environment variable is set in the same terminal where you run the script.
- “Model not found”: check the exact model name in the provider’s model list. Names change when new versions are released.
- Slow responses: large models and long prompts take longer. Try a faster model for testing.
Final thoughts
Managing a separate account for every AI provider made sense when there were only one or two good models. Today, with dozens of strong options, a single API key is simply more practical. You can test new models the day they launch, mix them in one project and keep all your spending in one place.
Set it up once, and switching between GPT, Claude, Gemini and the rest becomes as easy as changing one word in your code.