Gemini Generating Content
Gebruik de native API-indeling van Gemini via CometAPI voor tekstgeneratie, multimodale input, thinking/reasoning, Function Calling, Google Search-grounding, JSON-modus en Streaming.
CometAPI ondersteunt de native API-indeling van Gemini, waardoor je volledige toegang krijgt tot Gemini-specifieke functies zoals thinking control, Google Search-grounding, native image generation modalities en meer. Gebruik dit endpoint wanneer je mogelijkheden nodig hebt die niet beschikbaar zijn via het OpenAI-compatible chat endpoint.Documentation Index
Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
Use this file to discover all available pages before exploring further.
x-goog-api-key als Authorization: Bearer headers worden ondersteund voor authenticatie.Snelle start
Om een Gemini SDK of HTTP-client met CometAPI te gebruiken, vervang je de base URL en API key:| Setting | Google Default | CometAPI |
|---|---|---|
| Base URL | generativelanguage.googleapis.com | api.cometapi.com |
| API Key | $GEMINI_API_KEY | $COMETAPI_KEY |
Configureer thinking (reasoning)
Gemini-modellen kunnen interne redenering uitvoeren voordat ze een response genereren. De besturingsmethode hangt af van de modelgeneratie.- Gemini 3 (thinkingLevel)
- Gemini 2.5 (thinkingBudget)
thinkingLevel om de diepte van de redenering te regelen. Beschikbare niveaus: MINIMAL, LOW, MEDIUM, HIGH.Gebruik gemini-3-flash-preview als standaard voorbeeldmodel, tenzij je specifiek een andere Gemini 3-variant nodig hebt.Stream responses
Om Server-Sent Events te ontvangen terwijl het model content genereert, gebruik jestreamGenerateContent?alt=sse als operator. Elk SSE-event bevat een data:-regel met een JSON-GenerateContentResponse-object.
Stel system instructions in
Om het gedrag van het model gedurende het hele gesprek te sturen, gebruik jesystemInstruction:
JSON-uitvoer aanvragen
Om gestructureerde JSON-uitvoer af te dwingen, stel jeresponseMimeType in. Geef optioneel een responseSchema op voor strikte schemavalidatie:
Grounden met Google Search
Om realtime web search in te schakelen, voeg je eengoogleSearch tool toe:
groundingMetadata met bron-URL’s en confidence scores.
Response-voorbeeld
Een typische response van het Gemini-endpoint van CometAPI:thoughtsTokenCount in usageMetadata laat zien hoeveel tokens het model heeft besteed aan interne redenering, zelfs wanneer thinking-output niet in de response is opgenomen.Vergelijken met OpenAI-compatible endpoint
| Functie | Gemini Native (/v1beta/models/...) | OpenAI-Compatible (/v1/chat/completions) |
|---|---|---|
| Thinking-controle | thinkingConfig met thinkingLevel / thinkingBudget | Niet beschikbaar |
| Google Search-grounding | tools: [\{"google_search": \{\}\}] | Niet beschikbaar |
| Google Maps-grounding | tools: [\{"googleMaps": \{\}\}] | Niet beschikbaar |
| Beeldgeneratie-modality | responseModalities: ["IMAGE"] | Niet beschikbaar |
| Auth-header | x-goog-api-key of Bearer | Alleen Bearer |
| Response-formaat | Gemini-native (candidates, parts) | OpenAI-formaat (choices, message) |
Autorisaties
Your CometAPI key passed via the x-goog-api-key header. Bearer token authentication (Authorization: Bearer <key>) is also supported.
Padparameters
Gemini model ID. Example: gemini-3-flash-preview, gemini-2.5-pro. See the Models page for current options.
The operation to perform. Use generateContent for synchronous responses, or streamGenerateContent?alt=sse for Server-Sent Events streaming.
generateContent, streamGenerateContent?alt=sse Body
System instructions that guide the model's behavior across the entire conversation. Text only.
Tools the model may use to generate responses. Supports function declarations, Google Search, Google Maps, and code execution.
Configuration for tool usage, such as function calling mode.
Safety filter settings. Override default thresholds for specific harm categories.
Configuration for model generation behavior including temperature, output length, and response format.
The name of cached content to use as context. Format: cachedContents/{id}. See the Gemini context caching documentation for details.
Respons
Successful response. For streaming requests, the response is a stream of SSE events, each containing a GenerateContentResponse JSON object prefixed with data:.
The generated response candidates.
Feedback on the prompt, including safety blocking information.
Token usage statistics for the request.
The model version that generated this response.
The timestamp when this response was created (ISO 8601 format).
Unique identifier for this response.