OpenAI-compatible API: one line of code instead of ten subscriptions
Genosai serves 22 text models through an endpoint that is fully compatible with OpenAI. If your code already runs on the official OpenAI library, migrating takes two variables — base_url and the key. After that the same code talks to Claude, GPT, Gemini, DeepSeek, Qwen, MiniMax and Perplexity, billed from a single balance with no per-vendor subscriptions.
Updated: July 31, 2026
- One-line migration — Only base_url and the key change. The rest of your OpenAI library code stays untouched.
- 22 models, one key — Claude, GPT, Gemini, DeepSeek, Qwen, MiniMax and Perplexity all answer the same request shape.
- Pay per token — You are charged for actual usage, not a subscription. The exact amount ships in every response.
- Streaming and tools — Server-sent events and function calling are supported, so agent apps port over without rewrites.
- One balance for everything — Text, images, video, voice and music share the same account, key and prepaid balance.
Contents
- What is an OpenAI-compatible API
- How to start in one line
- Integration examples
- Available models
- Capabilities
- Pricing
- Comparison with direct provider access
- Connecting agents over MCP
- Limitations and tips
- FAQ
What is an OpenAI-compatible API
When OpenAI shipped its API, the request format quietly became an industry standard. Today almost every language-model library, every agent framework and every editor plugin speaks that dialect: a POST request with an array of messages, a response with an array of choices, streaming over server-sent events.
Genosai speaks the same dialect. The endpoint accepts the same fields — model, messages, stream, temperature, max_tokens, top_p — and returns an object with the same shape, right down to the field names inside usage and the structure of the error object. The practical consequence is simple: code written for OpenAI works against Genosai with no changes to its logic. Only the address changes.
That is different from the usual experience, where adding a model vendor means a new SDK, a new response schema and a separate code path for each case. Here there is one code path, and twenty-two models from five different families behind it. Compatibility covers failures too: when the balance runs out or a model is temporarily unavailable, your client library receives the familiar object with message, type and code fields and raises the same exception your code already handles.
How to start in one line
The whole setup takes a few minutes:
- Sign up for Genosai and top up the balance with any amount that suits you.
- Open your profile, go to the API keys section and create a key. It is shown once, so store it in your project environment variables straight away.
- In code, set base_url to
https://api.genosai.io/v1and pass the key you created. - Change the model name in the request to any id from the catalog.
- Run the application — nothing else needs touching.
You can create as many keys as you like, which makes it convenient to keep one key per service or per environment. If a key leaks or a contractor leaves, you revoke that single key without interrupting the other integrations.
Integration examples
In the official OpenAI library for Python, the address and key are set in the client constructor:
from openai import OpenAI
client = OpenAI(
base_url="https://api.genosai.io/v1",
api_key="sdk_live_your_key",
)
response = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Explain recursion in three sentences"}],
)
print(response.choices[0].message.content)
print(response.usage.model_extra["cost_credits"])
JavaScript works the same way:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.genosai.io/v1",
apiKey: process.env.GENOSAI_API_KEY,
});
const response = await client.chat.completions.create({
model: "gpt-5.4",
messages: [{ role: "user", content: "Write a SQL query for the top 10 customers" }],
});
If you are not using a library at all, a plain HTTP request does the job:
curl -sS -X POST "https://api.genosai.io/v1/chat/completions" \
-H "Authorization: Bearer sdk_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-flash",
"messages": [{ "role": "user", "content": "Hello" }]
}'
The same address goes into the environment variables that OpenAI-aware tools expect, usually the pair OPENAI_BASE_URL and OPENAI_API_KEY. That is how agent libraries, editor plugins and self-hosted chat interfaces connect.
Available models
The model id goes in the model field. The live list comes from the models endpoint, in the text section, together with prices, context size and flags for image input, web search and tool support.
| Family | Example models | Why it helps |
|---|---|---|
| Claude | Claude Sonnet 5, Claude Opus 4.8, Claude Haiku 4.5 | Context up to 800K tokens, careful code and prose |
| GPT | GPT-5.6 Sol, GPT-5.4, GPT-5.4 Mini | General reasoning, context up to 380K tokens |
| Gemini | Gemini 3 Flash, Gemini 2.5 Pro | Fast answers and low cost on high-volume work |
| DeepSeek | DeepSeek V4 Flash, DeepSeek V3.2 | Lowest token price with an 800K context |
| Search | Perplexity Pro, Perplexity | Answers grounded in fresh data from the web |
Switching models is a one-line change, so you can route bulk work such as email classification to a cheap model and reserve an expensive one for the rare hard requests. This is the kind of saving you get from routing inside your own code rather than from negotiating with a vendor.
Capabilities
Streaming turns on with the stream parameter. The response arrives in fragments as server-sent events, and the final fragment carries a usage block with the total spend:
stream = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Write a 200-word story"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Function calling works through the tools and tool_choice parameters. You describe the available functions with a JSON Schema, the model decides which one to call and returns tool_calls instead of text. You then run the function on your side and send the result back as a message with the tool role, exactly as in the OpenAI documentation:
tools = [{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Order status by id",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}]
Because of that, agent frameworks built around the loop of model calls function, application executes it, result goes back to the model port over to Genosai untouched. Every model supports tools except the Perplexity search models.
Images are accepted in the OpenAI format: an array of content parts where a part of type image_url carries a link or a data URI. Vision works on almost every model except DeepSeek, Qwen and Perplexity, and the flag is returned in the catalog. Web search is enabled with the web_search flag on Perplexity models and raises the request price by half.
Pricing
Billing happens after the model answers and is calculated separately for input and output tokens. Each model price is listed in the catalog in credits per million tokens. The minimum charge per request is 0.1 credits.
| Model | Input per 1M tokens | Output per 1M tokens |
|---|---|---|
| DeepSeek V4 Flash | 11.2 credits | 22.4 credits |
| Gemini 2.5 Flash Lite | 10 credits | 30 credits |
| Claude Haiku 4.5 | 80 credits | 400 credits |
| GPT-5.4 | 200 credits | 1200 credits |
| Claude Opus 4.8 | 480 credits | 2400 credits |
The key difference from a subscription is that idle months cost nothing. A short conversation usually costs a fraction of a credit, and the exact amount arrives in the response itself, in usage.cost_credits. That is handy when you need the unit economics of one operation inside your product: no reconciling logs against billing, the number is already there. A separate endpoint returns the current balance, and you can top it up on the Pricing page.
Comparison with direct provider access
| What you compare | Direct access per vendor | Genosai API |
|---|---|---|
| Contracts and payment | A separate account and card per vendor | One prepaid balance |
| Keys | Own key and dashboard for each | One key for all models |
| Code | Own SDK and response shape per vendor | One OpenAI format |
| Switching models | Rewrite the integration | Change one string in model |
| Media generation | Yet another vendor and key | Same key covers image, video, audio |
There is a flip side: the platform adds a markup over raw token cost, so at very large volume on a single model a direct vendor contract may end up cheaper. Genosai wins when you use several models, volumes are moderate, and developer time is worth more than the difference in token price.
Connecting agents over MCP
Besides REST, Genosai runs a Model Context Protocol server at genosai.io/mcp, which is how you give an AI agent direct access to the platform. It uses the same key.
Over MCP an agent gets a set of tools: chat with any text model, generate images and video, synthesize speech, create music, check the balance and poll task status. In Cursor and Claude Code the server is added through a config with an authorization header; in the Claude app it connects as a custom connector where you supply one URL and paste the key on the connect page.
In practice this means the assistant inside your editor can generate an illustration for an article or voice a script without ever leaving the conversation with you.
Limitations and tips
There is a limit of 15 requests per minute per account. For batch processing, add pauses between calls or use a queue, otherwise you will get a 429 response with a Retry-After header.
A single request accepts at most ten images. If you send more, the oldest ones are dropped and the request still goes through.
The deprecated functions and function_call fields, which OpenAI itself discourages, are rejected — use tools and tool_choice instead.
Parameters are clamped to their valid range automatically: temperature is bounded between 0 and 2, and the answer length between 256 and 32768 tokens. A value outside the range is trimmed rather than rejected with an error.
If a model returns nothing because of a provider hiccup, you are not charged: the platform answers with a 503 and leaves the balance alone. If the stream had already started and then broke, the charge does go through, because the provider has already counted the generated tokens.
The easiest way to start is a cheap model such as Gemini 3 Flash or DeepSeek V4 Flash: confirm the integration works, then point production at the flagships.
FAQ
What does OpenAI-compatible actually mean?
It means the endpoint accepts and returns data in exactly the format documented by OpenAI: the same request fields, the same response structure, the same error object. Because of that, the official OpenAI libraries for Python and JavaScript, plus any third-party tool that speaks OpenAI, connect to Genosai without a single change to your logic.
What do I change in existing code?
Two things: the API address and the key. Set base_url to https://api.genosai.io/v1 in the client constructor and pass a key that looks like sdk_live_..., created in your Genosai profile. Then switch the model name to any id from the catalog, for example claude-sonnet-5 or gpt-5.4. Everything else, including response handling and streaming, keeps working.
Which models are available through the API?
At the time of writing there are 22 text models: the GPT-5.4, GPT-5.5 and GPT-5.6 lines, Claude Opus, Sonnet and Haiku, Gemini 2.5 and 3.1, DeepSeek V3.2 and V4 Flash, Qwen3.5, MiniMax M2.7, and Perplexity with web search. The live list always comes from GET /v1/models in the text section.
How much does a request cost?
You pay for the tokens actually consumed, priced separately for input and output at the rate shown in the catalog. The minimum charge is 0.1 credits per request. The exact amount charged arrives in the usage.cost_credits field of the response, so per-call cost is visible immediately without opening a dashboard.
Are streaming and function calling supported?
Yes, both. Setting stream to true returns server-sent events exactly like OpenAI does. Function calling works through the tools and tool_choice parameters: the model returns tool_calls, you execute the function on your side and send the result back as a message with the tool role. That makes agent applications portable without rewrites.
Can I use it with LangChain or other frameworks?
Yes. Any framework that lets you override the OpenAI base URL will work, which covers most of them. Usually it is enough to set the OPENAI_BASE_URL and OPENAI_API_KEY environment variables to the Genosai values, and the framework picks them up without further configuration.
Can I connect the API to Cursor or Claude Code?
Yes, agents get a dedicated MCP server at genosai.io/mcp using the same key. It exposes tools for chatting with models, generating images and video, text-to-speech and music. In Cursor and Claude Code you add it through a config with an authorization header; in the Claude app it connects as a custom connector from a single URL.