Gemini Chat Completion API 신청 및 사용
Google Gemini는 매우 강력한 AI 대화 시스템으로, 프롬프트만 입력하면 단 몇 초 만에 유창하고 자연스러운 답변을 생성할 수 있습니다. Gemini는 놀라운 지능형 지원을 제공하여 인간의 업무 효율과 창의력을 크게 높여줍니다.
이 문서는 주로 Gemini Chat Completion API의 사용 절차를 소개하며, 이를 이용하면 공식 Gemini의 대화 기능을 쉽게 사용할 수 있습니다.
¶ 신청 절차
Gemini Chat Completion API를 사용하려면 먼저 零壹AI 콘솔에서 API Token을 발급받아 준비해 두세요.

아직 로그인하거나 가입하지 않았다면 로그인 페이지로 자동 이동하여 가입과 로그인을 안내하며, 완료 후 현재 페이지로 자동으로 돌아옵니다.
범용 애플리케이션의 API Key는 계정에 사용이 허용된 서비스에서 사용할 수 있으며, 전용 애플리케이션의 Key는 해당 애플리케이션의 서비스 범위에 따라 사용합니다. Key의 권한, 유효 기간 및 한도를 확인하고, 애플리케이션 잔액이 이번 요청의 비용을 지불하기에 충분한지 확인하세요. 사용 가능한 체험 할당량은 계정에 표시된 내용을 기준으로 하며, 잔액이 부족하면 「충전」 버튼을 클릭하면 됩니다.
📘 전체 문서: Gemini Chat Completion API →
¶ 기본 사용법
이제 그림과 같이 화면에서 해당 내용을 입력할 수 있습니다.

이 인터페이스를 처음 사용할 때는 최소한 세 가지 내용을 입력해야 합니다. 첫 번째는 authorization으로, 드롭다운 목록에서 바로 선택하면 됩니다. 다른 매개변수는 model이며, model은 우리가 선택하여 사용할 Gemini 공식 웹사이트의 모델 종류입니다. 선택 가능한 모델은 인터페이스 문서의 model 열거값을 기준으로 합니다. 마지막 매개변수는 messages이며, messages는 우리가 입력하는 질문 프롬프트의 배열입니다. 이는 배열이므로 여러 질문 프롬프트를 동시에 업로드할 수 있으며, 각 질문 프롬프트에는 role과 content가 포함됩니다. 이 중 role은 질문자의 역할을 나타내며, user, assistant, system의 세 가지 역할을 제공합니다. 다른 하나인 content는 우리가 질문하는 구체적인 내용입니다.
또한 오른쪽에 해당 호출 코드가 생성된 것을 확인할 수 있습니다. 코드를 복사하여 바로 실행하거나 「Try」 버튼을 직접 클릭하여 테스트할 수 있습니다.

참고:
gemini-3.x시리즈의 flash는 추론 모델로, 먼저 reasoning tokens를 소비합니다.max_tokens를 512보다 크게 설정하세요. 그렇지 않으면 빈 내용만 반환될 수 있습니다.gemini-3.8-flash는 현재 권장되는 Flash 모델로, 최대 100만 Token의 컨텍스트, 이미지 입력, 도구 호출 및 스트리밍 응답을 지원하며, 현재 Chat Completions 인터페이스를 통해 호출합니다.
gemini-4-argon도 Chat Completions에서 사용할 수 있으며, 일반 및 스트리밍 텍스트 응답을 지원합니다. 출력 예산의 일부를 추론에 사용할 수 있으므로 복잡한 작업에서는 max_tokens에 충분한 여유를 두세요. Google은 이 모델의 일반적인 작업에 최소 32768을 권장합니다. 이 인터페이스를 Google Interactions API의 백그라운드 긴 출력 기능과 동일하게 취급하지 마세요.
gemini-4-neon은 소프트웨어 엔지니어링과 자료 분석에 적합합니다. 요청 본문에서 model을 해당 ID로 설정하고, 추론과 본문을 위한 출력 Token을 확보하세요.
gemini-4-carbon과 gemini-4-hydrogen도 이 인터페이스의 일반 및 스트리밍 텍스트 응답을 지원합니다. Carbon은 복잡한 추론과 엔지니어링 작업을, Hydrogen은 일상적인 코딩과 다단계 작업을 대상으로 합니다. 두 모델 모두 추론 Token을 소비하므로 max_tokens에 충분한 예산을 확보해야 합니다. 네이티브 모델의 100만 Token 긴 출력이 이 인터페이스에서 해당 기능을 제공한다는 뜻은 아닙니다. 이미지 및 도구 호출 필드는 여전히 이 인터페이스의 공개 계약과 실제 반환 결과를 기준으로 합니다.
호출 후 반환 결과는 다음과 같습니다.
{
"id": "chatcmpl-20251122212413908150493uPhjTUO9",
"model": "gemini-3.5-flash",
"object": "chat.completion",
"created": 1763817866,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am a large language model, trained by Google.",
"reasoning_content": "**My Reasoning: Answering the User's Question**\n\nOkay, here's how I'm going to approach answering the user's question, \"What model are you?\". The core is to be direct and informative. First, I have to be clear about my origin. Then, I need to make sure the explanation is accessible, given that the user may not be familiar with technical jargon. I need to explain what a \"large language model\" actually *does*, and provide relatable examples. I know the user might be looking for a specific name, like other models have, so I'll address that directly and then wrap it up with an invitation to continue.\n\nSo, here's my plan:\n\n1. **Lead with the key info:** I'll begin by stating that I am a large language model created by Google. That is the fundamental, most critical piece of the puzzle.\n2. **Define the buzzword:** Then, I'll explain that \"large language model\" in simple terms. I'll explain what I *do* - process and generate text; how I *do* it - by training on huge amounts of text data; and the *goal* - to be able to communicate like a human.\n3. **Provide context:** After that, to make the concept even clearer, I'll provide a list of examples of my capabilities. I'll mention things like answering questions, summarizing texts, writing stories, translating languages, and brainstorming ideas.\n4. **Acknowledge the lack of a personal name:** I'll anticipate the likely question about a model name (like ChatGPT) by clearly stating that I don't have a personal name and that it's best to think of me as an AI assistant from Google.\n5. **End with an invitation:** Lastly, I'll end with a simple, friendly question to invite further interaction and to guide the conversation.\n\nWith this approach, I am confident I can successfully answer this important question.\n"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 932,
"total_tokens": 940,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 8,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 921
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"claude_cache_creation_5_m_tokens": 0,
"claude_cache_creation_1_h_tokens": 0
}
}
반환 결과에는 여러 필드가 있으며, 설명은 다음과 같습니다.
id, 이번 대화 작업에 대해 생성된 ID로, 이번 대화 작업을 고유하게 식별하는 데 사용됩니다.model, 선택한 Gemini 공식 웹사이트의 모델입니다.choices, Gemini가 질문 프롬프트에 대해 제공한 답변 정보입니다.usage: 이번 질의응답의 token 통계 정보입니다.
이 중 choices에는 Gemini의 답변 정보가 포함되어 있으며, 그 안의 choices는 Gemini가 답변한 구체적인 정보로, 그림과 같이 확인할 수 있습니다.

¶ 이미지 이해(멀티모달 입력)
Gemini는 네이티브 멀티모달 모델로, 직접 「이미지를 볼」 수 있습니다. 이미지를 전달하려면 메시지의 content를 문자열에서 콘텐츠 블록 배열로 바꾸고, 배열에 text 블록과 image_url 블록을 함께 넣으면 됩니다. 이는 OpenAI 및 공식 Gemini의 OpenAI 호환 형식과 완전히 일치합니다.
image_url.url은 두 가지 작성 방식을 지원합니다.
- base64
data:URI(권장, 가장 안정적): 형식은data:<미디어 유형>;base64,<데이터>이며, 예를 들면data:image/jpeg;base64,/9j/4AAQ...입니다. 미디어 유형(MIME)은 이미data:접두사에 작성되어 있으므로, 별도의media_type필드는 필요하지도 않고 존재하지도 않습니다. - 공개적으로 접근 가능한 이미지 URL: 예를 들면
https://cdn.acedata.cloud/4hfydw.jpg입니다.
지원되는 이미지 유형: png, jpeg, webp, heic, heif.
Python 호출 예제 코드(base64 data URI):
import base64
import requests
url = "https://api.01ai.cloud/gemini/chat/completions"
# 把本地图片读成 base64 data URI
with open("image.jpg", "rb") as f:
base64_image = base64.b64encode(f.read()).decode("utf-8")
data_uri = f"data:image/jpeg;base64,{base64_image}"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}",
"content-type": "application/json"
}
payload = {
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请用一句话描述这张图片。"},
{"type": "image_url", "image_url": {"url": data_uri}}
]
}
]
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
공개적으로 접근 가능한 이미지 URL을 직접 전달할 수도 있습니다.
payload = {
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请用一句话描述这张图片。"},
{"type": "image_url", "image_url": {"url": "https://cdn.acedata.cloud/4hfydw.jpg"}}
]
}
]
}
💡
image_url은url필드(값은 이미지 URL 또는 base64data:URI일 수 있음)와 선택적인detail필드만 허용합니다.media_type을 전달하지 마세요. 이는 Anthropic Claude의 이미지 필드이며, OpenAI / Gemini의image_url형식에 속하지 않습니다.
¶ 스트리밍 응답
이 인터페이스는 스트리밍 응답도 지원하며, 이는 웹 페이지 연동에 매우 유용해 웹 페이지에서 글자를 하나씩 표시하는 효과를 구현할 수 있습니다.
응답을 스트리밍으로 반환하려면 요청 헤더의 stream 매개변수를 true로 변경하면 됩니다.
그림과 같이 수정하되, 스트리밍 응답을 지원하려면 호출 코드도 그에 맞게 변경해야 합니다.

stream을 true로 변경하면 API가 해당 JSON 데이터를 한 줄씩 반환하며, 코드 수준에서 한 줄씩 결과를 얻으려면 그에 맞게 수정해야 합니다.
Python 호출 예제 코드:
import requests
url = "https://api.01ai.cloud/gemini/chat/completions"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}",
"content-type": "application/json"
}
payload = {
"model": "gemini-2.5-pro",
"messages": [{"role":"user","content":"Hello,What model are you?"}],
"stream": True,
"stream_options": {"include_usage": True}
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
출력 결과는 다음과 같습니다.
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {"content": "", "role": "assistant"}, "logprobs": null, "finish_reason": null, "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {"reasoning_content": "**Define My Nature**\n\nMy thinking has started. The user wants to know my nature, asking a direct \"what are you?\" The initial step was straightforward: identifying the query. Now, I recall my fundamental identity: I'm a large language model. This is the core truth I aim to convey.\n\n\n"}, "logprobs": null, "finish_reason": null, "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {"reasoning_content": "**Refining My Response**\n\nI've added the crucial information that I'm trained by Google to the basic \"large language model\" identity. My next step is considering what being a \"large language model\" actually entails, so I can explain my core capabilities. I'm focusing on providing context without going into specific technical details or model names. I want to convey my function in a way the user can easily understand.\n\n\n"}, "logprobs": null, "finish_reason": null, "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {"reasoning_content": "**Confirming Core Identity**\n\nI'm now solidifying my response. The user's query about my model affiliation needs a focused answer. I've pinpointed that \"trained by Google\" is essential, providing key context. I'm resisting the urge to mention any specific model names, as it's not relevant. The aim is to deliver a direct, accurate statement. My goal remains a clear and concise reply, avoiding technical jargon and getting straight to the relevant point.\n\n\n"}, "logprobs": null, "finish_reason": null, "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {"content": "I am a large language model, trained by Google."}, "logprobs": null, "finish_reason": null, "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": null, "choices": [{"delta": {}, "logprobs": null, "finish_reason": "stop", "index": 0}], "usage": null}
data: {"id": "chatcmpl-20251122214038810722821kNjUTjtr", "object": "chat.completion.chunk", "created": 1763818842, "model": "gemini-2.5-pro", "system_fingerprint": "", "choices": [], "usage": {"prompt_tokens": 8, "completion_tokens": 527, "total_tokens": 535, "prompt_tokens_details": {"cached_tokens": 0, "text_tokens": 8, "audio_tokens": 0, "image_tokens": 0}, "completion_tokens_details": {"text_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 519}, "input_tokens": 0, "output_tokens": 0, "input_tokens_details": null, "claude_cache_creation_5_m_tokens": 0, "claude_cache_creation_1_h_tokens": 0}}
data: [DONE]
보시다시피 응답에는 여러 개의 data가 있으며, data 안의 choices가 최신 답변 내용으로, 위에서 소개한 내용과 일치합니다. choices는 새로 추가된 답변 내용이며, 결과에 따라 이를 시스템에 연동할 수 있습니다. 또한 스트리밍 응답의 종료는 data의 내용에 따라 판단하며, 내용이 [DONE]이면 스트리밍 응답이 모두 종료되었음을 나타냅니다. 반환된 data 결과에는 여러 필드가 있으며, 소개는 다음과 같습니다.
id, 이번 대화 작업을 생성한 ID로, 이번 대화 작업을 고유하게 식별하는 데 사용됩니다.model, 선택한 Gemini 공식 웹사이트 모델입니다.choices, Gemini가 질문에 대해 제공한 답변 정보입니다.
JavaScript도 지원되며, 예를 들어 Node.js의 스트리밍 호출 코드는 다음과 같습니다.
const options = {
method: "POST",
headers: {
accept: "application/json",
authorization: "Bearer {token}",
"content-type": "application/json"
},
body: JSON.stringify({
model: "gemini-2.5-pro",
messages: [{ role: "user", content: "Hello, what model are you?" }],
stream: true
})
};
const response = await fetch("https://api.01ai.cloud/gemini/chat/completions", options);
const reader = response.body.getReader();
const decoder = new TextDecoder("utf-8");
while (true) {
const { value, done } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}
Java 예제 코드:
JSONObject jsonObject = new JSONObject();
jsonObject.put("model", "gemini-2.5-pro");
jsonObject.put("messages", new JSONArray().put(new JSONObject().put("role", "user").put("content", "Hello, what model are you?")));
jsonObject.put("stream", true);
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(jsonObject.toString(), mediaType);
Request request = new Request.Builder()
.url("https://api.01ai.cloud/gemini/chat/completions")
.post(body)
.addHeader("accept", "application/json")
.addHeader("authorization", "Bearer {token}")
.addHeader("content-type", "application/json")
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
다른 언어로는 직접 별도로 수정할 수 있으며, 원리는 모두 같습니다.
¶ 다중 턴 대화
다중 턴 대화 기능을 연동하려면 messages 필드에 여러 질문을 업로드해야 하며, 여러 질문의 구체적인 예시는 아래 그림과 같습니다.

Python 호출 예제 코드:
import requests
url = "https://api.01ai.cloud/gemini/chat/completions"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}",
"content-type": "application/json"
}
payload = {
"model": "gemini-2.5-pro",
"messages": [{"role":"user","content":"Hello"},{"role":"assistant","content":"Hello there! How can I help you today?"},{"role":"user","content":"What model are you?"}]
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
여러 질문을 업로드하면 다중 턴 대화를 쉽게 구현할 수 있으며, 다음과 같은 답변을 얻을 수 있습니다.
{
"id": "chatcmpl-20251122214426669120974AKFwnJd1",
"model": "gemini-2.5-pro",
"object": "chat.completion",
"created": 1763819072,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am a large language model, trained by Google.",
"reasoning_content": "Okay, here's how I'd approach this, thinking as a sophisticated AI:\n\nFirst, the user is directly querying my core identity: \"What model are you?\" That's a simple, straightforward question. My primary task is to provide accurate and helpful information, so I need to answer this immediately.\n\nRight off the bat, I know the answer. I *am* a large language model. That's my fundamental architecture and operational principle. I'm built on a vast network of connections and trained on a massive dataset.\n\nThen I must add the necessary context. Crucially, I have to provide the source of my training. I *was* trained by Google. That's a key identifier. It provides the user with valuable information about my origin and potential biases (though I'm trained to mitigate them).\n\nNow I must construct the response. My goal is to be factual, concise, and understandable.\n\nThe synthesized response is something like: \"I am a large language model, trained by Google.\"\n\nI have to assess the output: Does it meet the criteria? It's clear. It states what I am, it includes a critical piece of information on my origins, and it avoids jargon. No misleading promises.\n\nFinal verification: Does it actually answer the question? Yes. Is the information correct and truthful? Yes. Is it concise? Absolutely. Is the tone appropriate for any user? Yes. And, finally, this is the standard, approved response. Excellent.\n"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 16,
"completion_tokens": 265,
"total_tokens": 281,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 16,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 254
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"claude_cache_creation_5_m_tokens": 0,
"claude_cache_creation_1_h_tokens": 0
}
}
볼 수 있듯이, choices에 포함된 정보는 기본 사용의 내용과 일치하며, 여기에는 Gemini가 여러 대화에 대해 응답한 구체적인 내용이 포함되어 있어 여러 대화 내용을 바탕으로 해당 질문에 답할 수 있습니다.
¶ Gemini-3.0 멀티모달 모델
요청 예시:
{
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "图片的内容是什么?"
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.acedata.cloud/qzx2z1.png"
}
}
]
}
],
"stream": false
}
예시 결과:
{
"id": "chatcmpl-20251206001815715692730UVZe38kB",
"model": "gemini-3.1-pro-preview",
"object": "chat.completion",
"created": 1764951548,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "这是一张年轻女性的户外半身人像照片。\n\n以下是图片的主要内容描述:\n\n* **人物外貌**:照片中的女孩留着一头乌黑柔顺的长直发,五官清秀,皮肤白皙。她面带温柔的微笑,目光注视着镜头。\n* **穿着打扮**:她穿着一件米白色或浅杏色的泡泡袖上衣,外面搭配着黑色的衣物(看起来像是背带裙或马甲)。\n* **光影氛围**:阳光从左侧后方照射过来,洒在她的头发上,形成了一圈温暖的金黄色光晕,营造出一种清新、唯美的氛围。\n* **背景**:背景被虚化处理,可以看出是在户外,身后是一条空旷的路面(柏油路)以及路边的绿色树木。\n\n整体来看,这张照片给人一种甜美、阳光和邻家女孩的感觉。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1092,
"completion_tokens": 1271,
"total_tokens": 2363,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 4,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 1072
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"claude_cache_creation_5_m_tokens": 0,
"claude_cache_creation_1_h_tokens": 0
}
}
물론 동영상 링크를 전달할 수도 있으며, 구체적인 입력은 다음과 같습니다:
{
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "视频的内容是什么?"
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.acedata.cloud/58yioe.mp4"
}
}
]
}
],
"stream": false
}
예시 결과:
{
"id": "chatcmpl-20251206002711949677736JC9yL8AE",
"model": "gemini-3.1-pro-preview",
"object": "chat.completion",
"created": 1764952060,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "这段视频的内容充满趣味,主要展示了一只**橘猫**在黄昏时分的乡间公路上自信小跑的情景。\n\n具体细节如下:\n\n1. **画面内容**:\n * 主角是一只橘色的虎斑猫。\n * 背景是夕阳西下(或清晨)的时刻,光线金黄柔和。路边有木质栅栏和旷野,远处还有一个行人的剪影。\n * 镜头采用了低角度拍摄,时而拍摄猫咪迎面跑来,时而拍摄它离去的背影,还有猫咪面部和花纹的特写。\n\n2. **声音特点(关键点)**:\n * 视频的配音非常有特色。虽然画面是轻盈的猫咪在跑,但配上的声音却是**沉重且有节奏的马蹄声**(或者是类似木屐/高跟鞋敲击路面的声音)。\n * 这种声音与画面的反差制造了一种幽默感,仿佛这只猫咪把自己当成了一匹正在驰骋的骏马。\n\n总的来说,这是一个利用音画反差来制造萌点和笑点的宠物视频。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 915,
"completion_tokens": 1423,
"total_tokens": 2338,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 5,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 1162
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"claude_cache_creation_5_m_tokens": 0,
"claude_cache_creation_1_h_tokens": 0
}
}
위에서 Gemini 3.0 모델이 멀티모달 이해를 지원할 수 있음을 알 수 있습니다.
¶ Gemini-3.1 멀티모달 모델
gemini-3.1-pro-preview는 현재 Gemini 3.1 Pro의 공식 모델 ID로, 텍스트, 이미지, 동영상 등의 멀티모달 입력을 지원하며 복잡한 추론, 코딩 및 이해 작업에 적합합니다.
요청 예시:
{
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "图片的内容是什么?"
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.acedata.cloud/qzx2z1.png"
}
}
]
}
],
"stream": false
}
Gemini 3.1 Pro도 동영상 이해를 지원합니다:
{
"model": "gemini-3.1-pro-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "视频的内容是什么?"
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.acedata.cloud/58yioe.mp4"
}
}
]
}
],
"stream": false
}
반환 형식은 Gemini 3.0 Pro와 동일하며, 자세한 내용은 위의 Gemini-3.0 멀티모달 모델 섹션의 설명을 참조하세요.
¶ 오류 처리
API를 호출할 때 오류가 발생하면 API는 해당 오류 코드와 정보를 반환합니다. 예를 들어:
400 token_mismatched: 잘못된 요청으로, 매개변수가 누락되었거나 유효하지 않을 수 있습니다.400 api_not_implemented: 잘못된 요청으로, 매개변수가 누락되었거나 유효하지 않을 수 있습니다.401 invalid_token: 인증되지 않았으며, 인증 토큰이 유효하지 않거나 누락되었습니다.429 too_many_requests: 요청이 너무 많으며, 속도 제한을 초과했습니다.500 api_error: 내부 서버 오류로, 서버에서 문제가 발생했습니다.
¶ 오류 응답 예시
{
"success": false,
"error": {
"code": "api_error",
"message": "fetch failed"
},
"trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
¶ 결론
이 문서를 통해 Gemini Chat Completion API를 사용하여 공식 Gemini의 대화 기능을 쉽게 구현하는 방법을 알아보았습니다. 이 문서가 해당 API를 더 잘 연동하고 사용하는 데 도움이 되기를 바랍니다. 궁금한 점이 있으면 언제든지 기술 지원팀에 문의해 주세요.

