Skip to main content
POST
CometAPI는 Gemini 네이티브 API 형식을 지원하여 thinking control, Google Search 그라운딩, 네이티브 이미지 생성 modalities 등 Gemini 전용 기능을 완전히 활용할 수 있게 해줍니다. OpenAI-compatible chat endpoint에서 제공되지 않는 기능이 필요할 때 이 엔드포인트를 사용하세요.
전체 요청 필드, 응답 스키마, Gemini 모델별 동작에 대한 신뢰할 수 있는 기준 문서로 Google의 공식 GenerateContent API reference를 사용하세요. 이 CometAPI 페이지는 해당 네이티브 요청 형식을 CometAPI를 통해 전송하는 방법을 설명합니다.
Google이 네이티브 API를 업데이트함에 따라 Gemini 요청 파라미터와 응답 필드는 변경될 수 있습니다. 최신의 전체 파라미터 목록과 provider별 동작은 Gemini 텍스트 생성 문서에서 확인하세요.
인증에는 x-goog-api-keyAuthorization: Bearer 헤더를 모두 지원합니다.

빠른 시작

CometAPI와 함께 Gemini SDK 또는 HTTP 클라이언트를 사용하려면 base URL과 API key를 교체하세요:

비디오 입력 전송

Gemini generateContent는 비디오를 콘텐츠 파트로 받을 수 있습니다. 비디오가 저장된 위치에 따라 입력 형식을 선택하세요:
REST 및 curl 요청에서는 inlineData.mimeTypefileData.fileUri와 같은 Gemini의 camelCase 필드 이름을 사용하세요. URL 미디어를 file_data.file_uri로 보내지 마세요.
이 예제는 로컬 MP4 파일을 읽고, 이를 base64로 인코딩한 뒤, 요청 본문에 담아 전송합니다:
이 예제는 fileData.fileUri와 함께 공개 MP4 URL을 전송합니다:
CometAPI는 이 엔드포인트에 대해 별도의 Gemini Files API 업로드 흐름을 권장하지 않습니다. 미디어는 inlineData 또는 fileData.fileUri를 사용해 generateContent 요청 자체에서 전송하세요.

사고(thinking) 구성하기

Gemini 모델은 응답을 생성하기 전에 내부 추론을 수행할 수 있습니다. 제어 방식은 모델 세대에 따라 달라집니다.
Gemini 3 모델은 thinkingLevel을 사용해 추론 깊이를 제어합니다. 사용 가능한 수준: MINIMAL, LOW, MEDIUM, HIGH.특별히 다른 Gemini 3 변형이 필요한 경우가 아니라면 기본 예시 모델로 gemini-3-flash-preview를 사용하세요.
Gemini 2.5 모델에서 thinkingLevel을 사용하거나(Gemini 3 모델에서 thinkingBudget을 사용하는 경우도 포함) 하면 오류가 발생할 수 있습니다. 모델 버전에 맞는 올바른 parameter를 사용하세요.

응답 스트리밍(Streaming)

모델이 콘텐츠를 생성하는 동안 Server-Sent Events를 받으려면 연산자로 streamGenerateContent?alt=sse를 사용하세요. 각 SSE 이벤트에는 JSON GenerateContentResponse 객체가 들어 있는 data: 줄이 포함됩니다.

system instructions 설정

전체 대화에 걸쳐 모델의 동작을 안내하려면 systemInstruction을 사용하세요:

JSON 출력 요청

구조화된 JSON 출력을 강제하려면 responseMimeType을 설정하세요. 엄격한 스키마 검증을 위해 선택적으로 responseSchema를 제공할 수 있습니다:

Google Search로 grounding하기

실시간 웹 검색을 활성화하려면 googleSearch 도구를 추가하세요:
응답에는 소스 URL과 신뢰도 점수가 포함된 groundingMetadata가 포함됩니다.

응답 예시

CometAPI의 Gemini 엔드포인트에서 반환되는 일반적인 응답:
usageMetadatathoughtsTokenCount 필드는 thinking output이 응답에 포함되지 않더라도 모델이 내부 추론에 사용한 토큰 수를 보여줍니다.

OpenAI 호환 엔드포인트와 비교

인증

x-goog-api-key
string
header
필수

Your CometAPI key passed via the x-goog-api-key header. Bearer token authentication (Authorization: Bearer $COMETAPI_KEY) is also supported.

경로 매개변수

model
string
필수

Gemini model ID. Example: gemini-3-flash-preview, gemini-2.5-pro. See the Models page for current options.

operator
enum<string>
필수

The operation to perform. Use generateContent for synchronous responses, or streamGenerateContent?alt=sse for Server-Sent Events streaming.

사용 가능한 옵션:
generateContent,
streamGenerateContent?alt=sse

본문

application/json
contents
object[]

Conversation content. Each entry has an optional role (user or model) and a parts array.

systemInstruction
object

System instructions that guide the model's behavior across the entire conversation. Text only.

tools
object[]

Tools the model may use to generate responses. Supports function declarations, Google Search, Google Maps, and code execution.

toolConfig
object

Configuration for tool usage, such as function calling mode.

safetySettings
object[]

Safety filter settings. Override default thresholds for specific harm categories.

generationConfig
object

Configuration for model generation behavior including temperature, output length, and response format.

cachedContent
string

The name of cached content to use as context. Format: cachedContents/{id}. See the Gemini context caching documentation for details.

응답

200 - application/json

Successful response. For streaming requests, the response is a stream of SSE events, each containing a GenerateContentResponse JSON object prefixed with data:.

candidates
object[]

The generated response candidates.

promptFeedback
object

Feedback on the prompt, including safety blocking information.

usageMetadata
object

Token usage statistics for the request.

modelVersion
string

The model version that generated this response.

createTime
string

The timestamp when this response was created (ISO 8601 format).

responseId
string

Unique identifier for this response.