Gemini native API
Call Gemini models with Google's official generateContent API, compatible with the Google GenAI SDK and Gemini CLI.
Endpoint
POST https://api.onefast.ai/v1beta/models/{model}:generateContent
POST https://api.onefast.ai/v1beta/models/{model}:streamGenerateContent?alt=sse
x-goog-api-key: sk-xxx
Request and response formats match Google's official Gemini API. Pass the key in the x-goog-api-key header or as the query parameter ?key=sk-xxx.
Basic request
cURL
curl "https://api.onefast.ai/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Explain how AI works in one sentence."}]}]
}'
Python
# pip install google-genai
from google import genai
from google.genai import types
client = genai.Client(
api_key="sk-xxx",
http_options=types.HttpOptions(base_url="https://api.onefast.ai"),
)
resp = client.models.generate_content(
model="gemini-2.5-flash",
contents="Explain how AI works in one sentence.",
)
print(resp.text)
Node.js
// npm install @google/genai
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "sk-xxx", httpOptions: { baseUrl: "https://api.onefast.ai" } });
const resp = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: "Explain how AI works in one sentence.",
});
console.log(resp.text);
Streaming
Use :streamGenerateContent, and you must add ?alt=sse; otherwise the response comes back all at once, non-streamed:
cURL
curl -N "https://api.onefast.ai/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Count from 1 to 5."}]}]}'
Thinking settings
Gemini 2.5 and later models think by default, and thinking tokens count as output (usageMetadata.thoughtsTokenCount in the response). Control it with thinkingConfig:
{
"contents": [{"role": "user", "parts": [{"text": "..."}]}],
"generationConfig": {
"thinkingConfig": {"thinkingBudget": 1024, "includeThoughts": false}
}
}
OpenAI format works too
If you'd rather not add the Google SDK, call Gemini models through the Chat completions endpoint with model set to gemini-2.5-flash.