Gemini 콘텐츠 생성
CometAPI를 통해 Gemini 네이티브 API 형식을 사용하여 텍스트 생성, 멀티모달 입력, thinking/reasoning, 함수 호출(Function Calling), Google Search grounding, JSON 모드, 스트리밍(Streaming)을 활용하세요.
CometAPI는 Gemini 네이티브 API 형식을 지원하므로 thinking 제어, Google Search grounding, 네이티브 이미지 생성 modality 등 Gemini 전용 기능을 완전히 활용할 수 있습니다. OpenAI 호환 채팅 엔드포인트에서 제공되지 않는 기능이 필요할 때 이 엔드포인트를 사용하세요.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와 Authorization: Bearer 헤더를 모두 지원합니다.빠른 시작
CometAPI와 함께 Gemini SDK 또는 HTTP 클라이언트를 사용하려면 base URL과 API 키를 교체하세요:| Setting | Google Default | CometAPI |
|---|---|---|
| Base URL | generativelanguage.googleapis.com | api.cometapi.com |
| API Key | $GEMINI_API_KEY | $COMETAPI_KEY |
thinking 구성하기 (reasoning)
Gemini 모델은 응답을 생성하기 전에 내부 추론(Inference)을 수행할 수 있습니다. 제어 방식은 모델 세대에 따라 달라집니다.- Gemini 3 (thinkingLevel)
- Gemini 2.5 (thinkingBudget)
thinkingLevel을 사용합니다. 사용 가능한 수준: MINIMAL, LOW, MEDIUM, HIGH.특별히 다른 Gemini 3 variant가 필요한 경우가 아니라면 기본 예제 모델로 gemini-3-flash-preview를 사용하세요.응답 스트리밍하기
모델이 콘텐츠를 생성하는 동안 Server-Sent Events를 받으려면 operator로streamGenerateContent?alt=sse를 사용하세요. 각 SSE 이벤트에는 JSON GenerateContentResponse 객체가 들어 있는 data: 줄이 포함됩니다.
시스템 지침 설정하기
대화 전체에서 모델의 동작을 안내하려면systemInstruction을 사용하세요:
요청 JSON 출력
구조화된 JSON 출력을 강제하려면responseMimeType를 설정하세요. 엄격한 스키마 검증을 위해 선택적으로 responseSchema를 제공할 수도 있습니다:
Google Search로 그라운딩
실시간 웹 검색을 활성화하려면googleSearch 도구를 추가하세요:
groundingMetadata가 포함됩니다.
응답 예시
CometAPI의 Gemini 엔드포인트에서 반환되는 일반적인 응답은 다음과 같습니다:usageMetadata의 thoughtsTokenCount 필드는 사고 출력이 응답에 포함되지 않더라도, 모델이 내부 추론에 사용한 토큰 수를 보여줍니다.OpenAI 호환 엔드포인트와 비교
| 기능 | Gemini 네이티브 (/v1beta/models/...) | OpenAI 호환 (/v1/chat/completions) |
|---|---|---|
| Thinking 제어 | thinkingConfig에서 thinkingLevel / thinkingBudget 사용 | 사용 불가 |
| Google Search 그라운딩 | tools: [\{"google_search": \{\}\}] | 사용 불가 |
| Google Maps 그라운딩 | tools: [\{"googleMaps": \{\}\}] | 사용 불가 |
| 이미지 생성 modality | responseModalities: ["IMAGE"] | 사용 불가 |
| 인증 헤더 | x-goog-api-key 또는 Bearer | Bearer만 지원 |
| 응답 형식 | Gemini 네이티브 (candidates, parts) | OpenAI 형식 (choices, message) |
인증
Your CometAPI key passed via the x-goog-api-key header. Bearer token authentication (Authorization: Bearer <key>) is also supported.
경로 매개변수
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 본문
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.
응답
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.