순수 텍스트 대화 외에도 YouRouter는 멀티모달 모델 호출을 지원합니다. 이미지, 시각 이해, 제공업체 네이티브 멀티모달 형식 또는 영상 생성 작업이 필요할 때 이 페이지를 사용하세요.
어떤 API를 써야 할까요?
| 사용 사례 | 권장 API | 설명 |
|---|
| 텍스트 대화 | POST /v1/chat/completions | 표준 OpenAI 호환 호출. |
| 이미지 이해 | POST /v1/chat/completions | 텍스트와 image_url 콘텐츠 블록을 함께 전송. |
| Gemini 네이티브 멀티모달 | POST /v1/projects/...:generateContent | Google 네이티브 contents / parts 구조가 필요할 때. |
| Claude 네이티브 messages | POST /v1/messages | Anthropic 네이티브 Messages 형식이 필요할 때. |
| 텍스트-투-비디오 / 이미지-투-비디오 | POST /api/v3/contents/generations/tasks | 작업 기반 생성: 작업 생성 후 결과를 폴링. |
대부분의 채팅 및 시각 연동에는 https://api.yourouter.ai/v1과 OpenAI 호환 Chat Completions 형식부터 시작하는 것을 권장합니다.
Chat Completions로 이미지 입력 보내기
messages[].content를 콘텐츠 블록 배열로 설정합니다. 일반적으로 text 블록 하나와 하나 이상의 image_url 블록을 포함합니다.
curl https://api.yourouter.ai/v1/chat/completions \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
]
}'
생성 결과는 보통 다음 위치에 있습니다.
choices[0].message.content
Base64 이미지 입력
비공개 이미지는 data URL을 직접 보낼 수 있습니다.
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,<BASE64_IMAGE>"
}
}
페이로드 크기는 가능한 한 작게 유지하세요. 매우 큰 이미지는 임시 HTTPS URL 사용을 권장합니다.
Python 예시
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YOUROUTER_API_KEY"],
base_url="https://api.yourouter.ai/v1",
)
with open("image.jpg", "rb") as image_file:
encoded = base64.b64encode(image_file.read()).decode("utf-8")
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is shown in this image?"},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{encoded}"
},
},
],
}
],
)
print(completion.choices[0].message.content)
Gemini 네이티브 멀티모달
연동이 Gemini 네이티브 필드에 의존하는 경우 Google의 generateContent 형식을 사용합니다.
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "vendor: google" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Describe this image in one sentence." },
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "<BASE64_IMAGE>"
}
}
]
}
]
}'
레퍼런스 페이지는 Google Generate Content를 참고하세요.
Claude 네이티브 Messages
Claude 네이티브 요청 동작이 필요하면 Anthropic Messages 형식을 사용합니다.
curl https://api.yourouter.ai/v1/messages \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "vendor: anthropic" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 300,
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe this image in one sentence." },
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "<BASE64_IMAGE>"
}
}
]
}
]
}'
레퍼런스 페이지는 Anthropic Messages를 참고하세요.
영상 생성 작업
영상 생성은 작업 기반입니다. 작업을 만든 뒤 완료될 때까지 폴링합니다.
curl -X POST https://api.yourouter.ai/api/v3/contents/generations/tasks \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-1-0-pro-250528",
"content": [
{
"type": "text",
"text": "A cinematic product shot with soft studio lighting --duration 5 --resolution 1080p"
}
]
}'
생성 호출은 작업 id를 반환합니다. 이후 해당 id로 상태를 조회합니다.
curl https://api.yourouter.ai/api/v3/contents/generations/tasks/{id} \
-H "Authorization: Bearer $YOUROUTER_API_KEY"
전체 작업 흐름은 Ark 텍스트-투-비디오를 참고하세요.
연동 팁
- 모델 ID는 설정으로 관리해 시각·멀티모달 모델 전환 시 코드 변경을 최소화하세요.
- 제공업체 특유의 형식이나 동작이 분명히 필요할 때만
vendor를 사용하세요.
- 큰 파일은 HTTPS 이미지 URL을 우선하고, 비공개나 로컬 테스트에는 base64 data URL이 적합합니다.
- 제공업체별 멀티모달 문제를 해결할 때는 응답의 요청 ID를 보존하세요.