Chat Completions API는 Python 및 REST용 OpenAI 라이브러리를 사용하여 Vertex AI의 Gemini와 더 쉽게 상호작용할 수 있도록 설계된 OpenAI 호환 엔드포인트로 작동합니다. 이미 OpenAI 라이브러리를 사용하고 있다면 이 API를 사용하여 OpenAI 모델 호출과 Vertex AI 호스팅 모델 간에 전환하여 기존 코드를 변경하지 않고도 출력, 비용, 확장성을 비교할 수 있습니다.
아직 OpenAI 라이브러리를 사용하고 있지 않다면 Google 생성형 AI SDK를 사용하는 것이 좋습니다.
지원되는 모델
Chat Completions API는 Gemini 모델과 Model Garden에서 자체 배포한 일부 모델을 모두 지원합니다.
Google 모델의 경우 Chat Completions API는 다음 OpenAI 파라미터를 지원합니다. 각 파라미터에 대한 설명은 OpenAI의 채팅 완성 생성 문서를 참고하세요.
서드 파티 모델의 파라미터 지원은 모델마다 다릅니다. 지원되는 매개변수를 확인하려면 모델의 문서를 참조하세요.
messages
System message
User message: text 및 image_url 유형이 지원됩니다. image_url 유형은 Cloud Storage URI에 저장된 이미지 또는 "data:<MIME-TYPE>;base64,<BASE64-ENCODED-BYTES>" 형식의 base64 인코딩을 지원합니다. Cloud Storage 버킷을 만들고 여기에 파일을 업로드하는 방법을 알아보려면 객체 스토리지 탐색을 참고하세요.
detail 옵션은 지원되지 않습니다.
Assistant message
Tool message
Function message: 이 필드는 지원 중단되었지만 이전 버전과의 호환성을 위해 지원됩니다.
model
max_completion_tokens
max_tokens의 별칭입니다.
max_tokens
n
frequency_penalty
presence_penalty
reasoning_effort
대답에 사용되는 시간과 토큰 수를 구성합니다.
low: 1024
medium: 8192
high: 24576
대답에 생각이 포함되지 않으므로 reasoning_effort 또는 extra_body.google.thinking_config 중 하나만 지정할 수 있습니다.
response_format
json_object: Gemini API에 'application/json'을 전달하는 것으로 해석됩니다.
json_schema.
완전 재귀 스키마는 지원되지 않습니다. additional_properties가 지원됩니다.
text: Gemini API에 'text/plain'을 전달하는 것으로 해석됩니다.
다른 모든 MIME 유형은 'application/json'을 직접 전달하는 것처럼 모델에 그대로 전달됩니다.
seed
GenerationConfig.seed에 해당합니다.
stop
stream
temperature
top_p
tools
type
function
name
description
parameters: OpenAPI 사양을 사용하여 파라미터를 지정합니다.
이는 JSON 스키마 객체로 설명되는 OpenAI 파라미터 필드와 다릅니다. OpenAPI와 JSON 스키마 간의 키워드 차이점에 관한 자세한 내용은 OpenAPI 가이드를 참고하세요.
data: 모든 URI 또는 유효한 blob 형식 이미지, 오디오, 동영상을 비롯한 모든 blob 유형을 지원합니다. GenerateContent에서 지원하는 모든 항목 (HTTP, Cloud Storage 등)이 지원됩니다.
format: OpenAI는 wav (audio/wav)와 mp3 (audio/mp3)를 모두 지원합니다. Gemini를 사용하면 모든 유효한 MIME 유형이 지원됩니다.
image_url
data:input_audio와 마찬가지로 모든 URI 또는 유효한 blob 형식이 지원됩니다.
URL인 image_url은 기본적으로 image/* MIME 유형을 사용하며 blob 데이터인 image_url은 모든 멀티모달 입력으로 사용할 수 있습니다.
detail:미디어 해상도와 유사하며 요청의 이미지당 최대 토큰 수를 결정합니다. OpenAI의 필드는 이미지별로 적용되지만 Gemini는 요청 전체에 동일한 세부정보를 적용하며, 하나의 요청에 여러 세부정보 유형을 전달하면 오류가 발생합니다.
일반적으로 data 매개변수는 URI이거나 MIME 유형과 base64로 인코딩된 바이트의 조합("data:<MIME-TYPE>;base64,<BASE64-ENCODED-BYTES>" 형식)일 수 있습니다.
MIME 유형의 전체 목록은 GenerateContent을 참고하세요.
OpenAI의 base64 인코딩에 대한 자세한 내용은 문서를 참고하세요.
사고가 지원되는 모델의 경우 모델의 사고를 대답과 분리하는 데 사용됩니다.
지정하지 않으면 모델의 생각에 태그가 반환되지 않습니다. 있는 경우 후속 질문에서는 생각 태그를 삭제하고 컨텍스트에 맞게 생각을 적절하게 표시합니다. 이렇게 하면 후속 쿼리에 적절한 컨텍스트를 유지할 수 있습니다.
기능 extra_part개
extra_part를 사용하면 Part 수준에서 추가 설정을 지정할 수 있습니다.
Gemini 전용 extra_part 기능을 포함하는 google 필드를 포함합니다.
{...,"extra_part":{"google":{...,// Add extra_part features here.}}}
extra_content
무시해서는 안 되는 Gemini 전용 콘텐츠를 추가하는 필드입니다.
thought
필드가 생각인지 명시적으로 표시합니다 (thought_tag_marker보다 우선함). 도구 호출이 생각의 일부인지 여부를 지정하는 데 사용해야 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Using OpenAI libraries with Vertex AI\n\n| To see an example of using the Chat Completions API,\n| run the \"Call Gemini with the OpenAI Library\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/chat-completions/intro_chat_completions_api.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fchat-completions%2Fintro_chat_completions_api.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fchat-completions%2Fintro_chat_completions_api.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/chat-completions/intro_chat_completions_api.ipynb)\n\nThe Chat Completions API works as an Open AI-compatible endpoint, designed to\nmake it easier to interface with Gemini on Vertex AI by\nusing the OpenAI libraries for Python and REST. If you're already using the\nOpenAI libraries, you can use this API as a low-cost way to switch between\ncalling OpenAI models and Vertex AI hosted models to compare\noutput, cost, and scalability, without changing your existing code.\nIf you aren't already using the OpenAI libraries, we recommend that you\n[use the Google Gen AI SDK](/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal).\n\nSupported models\n----------------\n\nThe Chat Completions API supports both Gemini models and select\nself-deployed models from Model Garden.\n\n### Gemini models\n\nThe following models provide support for the Chat Completions API:\n\n- [Gemini 2.5 Pro](/vertex-ai/generative-ai/docs/models/gemini/2-5-pro)\n- [Gemini 2.5 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash)\n- [Gemini 2.0 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash)\n- [Gemini 2.0 Flash-Lite](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash-lite)\n\n### Self-deployed models from Model Garden\n\nThe\n[Hugging Face Text Generation Interface (HF TGI)](https://huggingface.co/docs/text-generation-inference/en/index)\nand\n[Vertex AI Model Garden prebuilt vLLM](http://us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve)\ncontainers support the Chat Completions API. However,\nnot every model deployed to these containers supports the Chat Completions API.\nThe following table includes the most popular supported models by container:\n\nSupported parameters\n--------------------\n\nFor Google models, the Chat Completions API supports the following OpenAI\nparameters. For a description of each parameter, see OpenAI's documentation on\n[Creating chat completions](https://platform.openai.com/docs/api-reference/chat/create).\nParameter support for third-party models varies by model. To see which parameters\nare supported, consult the model's documentation.\n\nIf you pass any unsupported parameter, it is ignored.\n\n### Multimodal input parameters\n\nThe Chat Completions API supports select multimodal inputs.\n\nIn general, the `data` parameter can be a URI or a combination of MIME type and\nbase64 encoded bytes in the form `\"data:\u003cMIME-TYPE\u003e;base64,\u003cBASE64-ENCODED-BYTES\u003e\"`.\nFor a full list of MIME types, see [`GenerateContent`](/vertex-ai/generative-ai/docs/model-reference/inference#blob).\nFor more information on OpenAI's base64 encoding, see [their documentation](https://platform.openai.com/docs/guides/images-vision#giving-a-model-images-as-input).\n\nFor usage, see our [multimodal input examples](/vertex-ai/generative-ai/docs/migrate/openai/examples#multimodal_input_examples).\n\n### Gemini-specific parameters\n\nThere are several features supported by Gemini that are not available in OpenAI models.\nThese features can still be passed in as parameters, but must be contained within an\n`extra_content` or `extra_body` or they will be ignored.\n\n### `extra_body` features\n\nInclude a `google` field to contain any Gemini-specific\n`extra_body` features. \n\n {\n ...,\n \"extra_body\": {\n \"google\": {\n ...,\n // Add extra_body features here.\n }\n }\n }\n\n### `extra_part` features\n\n`extra_part` lets you specify additional settings at a per-`Part` level.\n\nInclude a `google` field to contain any Gemini-specific\n`extra_part` features. \n\n {\n ...,\n \"extra_part\": {\n \"google\": {\n ...,\n // Add extra_part features here.\n }\n }\n }\n\nWhat's next\n-----------\n\n- Learn more about [authentication and credentialing](/vertex-ai/generative-ai/docs/migrate/openai/auth-and-credentials) with the OpenAI-compatible syntax.\n- See examples of calling the [Chat Completions API](/vertex-ai/generative-ai/docs/migrate/openai/examples) with the OpenAI-compatible syntax.\n- See examples of calling the [Inference API](/vertex-ai/generative-ai/docs/model-reference/inference#examples) with the OpenAI-compatible syntax.\n- See examples of calling the [Function Calling API](/vertex-ai/generative-ai/docs/model-reference/function-calling#examples) with OpenAI-compatible syntax.\n- Learn more about the [Gemini API](/vertex-ai/generative-ai/docs/overview).\n- Learn more about [migrating from Azure OpenAI to the Gemini API](/vertex-ai/generative-ai/docs/migrate/migrate-from-azure-to-gemini)."]]