Other Clients & Protocols
Gemini compatible
The generateContent endpoint, for the Google GenAI SDK and Gemini models.
For the official Google GenAI SDK and Gemini CLI. The key’s group must support Gemini. Gemini models can also be accessed using the OpenAI compatible protocol where supported.
Endpoint and authentication
YOUR_API_KEY in the examples is a placeholder and will not work as copied. Sign in to pick one of your keys and fill it into every example on this page.
Sign in to fill in keyhttps://api.keyvia.ccRoot URL, without /v1beta
POST https://api.keyvia.cc/v1beta/models/gemini-flash-latest:generateContentUse the authentication header x-goog-api-key: YOUR_API_KEY. Gemini’s path prefix is /v1beta. Enter the root URL in the SDK; it appends the path.
Minimal request
The reply is in candidates[0].content.parts[0].text. The SDK provides a .text convenience property.
curl "https://api.keyvia.cc/v1beta/models/gemini-flash-latest:generateContent" \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "contents": [{ "parts": [{ "text": "Reply only: Hello" }] }] }'from google import genai
client = genai.Client(api_key="YOUR_API_KEY", http_options={"base_url": "https://api.keyvia.cc"})
resp = client.models.generate_content(model="gemini-flash-latest", contents="Reply only: Hello")
print(resp.text)import { GoogleGenAI } from '@google/genai'
const ai = new GoogleGenAI({ apiKey: 'YOUR_API_KEY', httpOptions: { baseUrl: 'https://api.keyvia.cc' } })
const resp = await ai.models.generateContent({ model: 'gemini-flash-latest', contents: 'Reply only: Hello' })
console.log(resp.text)Streaming
Replace generateContent with streamGenerateContent?alt=sse to receive SSE events. In the SDK, use generate_content_stream.
from google import genai
client = genai.Client(api_key="YOUR_API_KEY", http_options={"base_url": "https://api.keyvia.cc"})
for chunk in client.models.generate_content_stream(model="gemini-flash-latest", contents="Introduce yourself in one sentence"):
print(chunk.text, end="", flush=True)See available models in the Model catalog; for failed requests, see Error codes. If a failed request URL contains /v1/ instead of /v1beta/, remove /v1 from the SDK’s base URL.