Gemini Generating Content
Metin üretimi, multimodal girdi, düşünme/akıl yürütme, function calling, Google Search grounding, JSON mode ve Streaming için CometAPI üzerinden Gemini yerel API biçimini kullanın.
CometAPI, Gemini’ye özgü düşünme kontrolü, Google Search grounding, yerel görüntü üretim modaliteleri ve daha fazlasına tam erişim sağlayan Gemini yerel API biçimini destekler. OpenAI-compatible chat endpoint üzerinden sunulmayan yeteneklere ihtiyaç duyduğunuzda bu endpoint’i kullanın.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 hem de Authorization: Bearer başlıkları desteklenir.Hızlı başlangıç
CometAPI ile herhangi bir Gemini SDK’sı veya HTTP istemcisi kullanmak için base URL’yi ve API anahtarını değiştirin:| Ayar | Google varsayılanı | CometAPI |
|---|---|---|
| Base URL | generativelanguage.googleapis.com | api.cometapi.com |
| API Key | $GEMINI_API_KEY | $COMETAPI_KEY |
Düşünmeyi yapılandırma (akıl yürütme)
Gemini modelleri, yanıt üretmeden önce dahili akıl yürütme yapabilir. Kontrol yöntemi model nesline bağlıdır.- Gemini 3 (thinkingLevel)
- Gemini 2.5 (thinkingBudget)
thinkingLevel kullanır. Kullanılabilir seviyeler: MINIMAL, LOW, MEDIUM, HIGH.Özellikle farklı bir Gemini 3 varyantına ihtiyacınız yoksa varsayılan örnek model olarak gemini-3-flash-preview kullanın.Yanıtları stream etme
Model içerik üretirken Server-Sent Events almak için operatör olarakstreamGenerateContent?alt=sse kullanın. Her SSE olayı, JSON GenerateContentResponse nesnesi içeren bir data: satırı barındırır.
Sistem talimatlarını ayarlama
Tüm konuşma boyunca modelin davranışını yönlendirmek içinsystemInstruction kullanın:
İstek JSON çıktısı
Yapılandırılmış JSON çıktısını zorlamak içinresponseMimeType ayarlayın. Sıkı şema doğrulaması için isteğe bağlı olarak bir responseSchema sağlayın:
Google Search ile grounding
Gerçek zamanlı web aramasını etkinleştirmek için birgoogleSearch aracı ekleyin:
groundingMetadata içerir.
Yanıt örneği
CometAPI’nin Gemini endpoint’inden tipik bir yanıt:usageMetadata içindeki thoughtsTokenCount alanı, düşünme çıktısı yanıta dahil edilmese bile modelin dahili muhakeme için kaç token harcadığını gösterir.OpenAI uyumlu endpoint ile karşılaştırma
| Özellik | Gemini Native (/v1beta/models/...) | OpenAI-Compatible (/v1/chat/completions) |
|---|---|---|
| Düşünme kontrolü | thinkingConfig ile thinkingLevel / thinkingBudget | Kullanılamaz |
| Google Search grounding | tools: [\{"google_search": \{\}\}] | Kullanılamaz |
| Google Maps grounding | tools: [\{"googleMaps": \{\}\}] | Kullanılamaz |
| Görsel üretim modality | responseModalities: ["IMAGE"] | Kullanılamaz |
| Kimlik doğrulama header’ı | x-goog-api-key veya Bearer | Yalnızca Bearer |
| Yanıt biçimi | Gemini yerel biçimi (candidates, parts) | OpenAI biçimi (choices, message) |
Yetkilendirmeler
Your CometAPI key passed via the x-goog-api-key header. Bearer token authentication (Authorization: Bearer <key>) is also supported.
Yol Parametreleri
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 Gövde
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.
Yanıt
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.