Gemini v1beta
Call Gemini’s native v1beta interface through Runtoken.
Prerequisites#
Before you start, prepare:
- A platform API key created in the console.
- The exact ID of a model using Gemini v1beta.
- A server-side HTTP environment; the streaming example uses curl.
Endpoint and authentication#
Send the platform key in x-goog-api-key.
/v1beta/models/{model}:streamGenerateContentUse the gateway host https://api.runtoken.net. This native endpoint is not under /v1.
Send a request#
This streaming example uses alt=sse and a contents array containing text parts.
curl -N \
'https://api.runtoken.net/v1beta/models/YOUR_MODEL_ID:streamGenerateContent?alt=sse' \
-H 'x-goog-api-key: YOUR_PLATFORM_KEY' \
-H 'Content-Type: application/json' \
-d '{
"contents": [{
"role": "user",
"parts": [{ "text": "Hello!" }]
}]
}'Replace these placeholders before running the example.
| Placeholder | Replace with |
|---|---|
YOUR_PLATFORM_KEY | Your platform API key from the console. |
YOUR_MODEL_ID | A Gemini model ID from the catalogue; placed in the URL. |
Keep these parts of the request URL unchanged.
| URL component | Purpose |
|---|---|
:streamGenerateContent | Keep this method suffix after the model ID. |
?alt=sse | Keep this query parameter for the streaming request. |
Process the stream#
Read the response as Gemini protocol data. curl -N disables output buffering; it does not turn Gemini events into an OpenAI response format.
Inference is stateless. Keep conversation context in your application and include the relevant content in later requests.
Model-specific input#
This example covers text input. Image or other media input, generation options and tool support need confirmation for the model you select.
Explicit cache and file resources are not supported. Do not build an integration that depends on uploading a persistent file resource or referring to an explicit cache object.
Next steps#
For a dedicated vector endpoint, see Embeddings. Shared routing and billing behavior is documented in the integration guide.