채팅 완료
하나의 API로 100개 이상의 모델에 걸쳐 채팅 응답을 생성합니다. OpenAI 채팅 완료, Anthropic 메시지 및 Anthropic 응답과 즉시 호환됩니다.
입증
모든 요청에는 Bearer 토큰(Airforce API 키)이 필요합니다. 인류학 x-api-key 헤더도 허용됩니다. /v1/messages SDK 호환성을 위해.
Authorization: Bearer sk-air-YOUR_API_KEY
# alt for /v1/messages:
x-api-key: sk-air-YOUR_API_KEYPOST /v1/chat/completions
OpenAI 호환 채팅 완료. 공무원과 협력 openai 재정의를 통한 SDK base_url 에게 https://api.airforce/v1.
https://api.airforce/v1/chat/completions요청 본문
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | 모델 ID. 사용 가능한 ID를 검색하려면 GET /v1/models를 사용하세요. |
| messages | array | Required | 대화 기록. 각 항목에는 { 역할: "시스템" | "사용자" | "보조" | "도구", 내용 }. 콘텐츠는 문자열 또는 콘텐츠 블록의 배열입니다(비전, 아래 참조). |
| max_tokens | integer | Optional | 생성할 최대 토큰 수입니다. 모델의 max_output_tokens로 제한됩니다. |
| temperature | float | Optional | 샘플링 온도, 0–2. 낮을수록 더 결정적입니다. 기본값은 업스트림 공급자에 따라 다릅니다. |
| top_p | float | Optional | 핵 샘플링. 온도나 top_p 중 하나만 사용하고 둘 다 사용하지는 마세요. |
| stream | boolean | Optional | true인 경우 응답은 서버에서 보낸 이벤트의 스트림입니다. 아래의 "스트리밍"을 참조하세요. |
| stream_options | object | Optional | { include_usage: 부울 }. include_usage가 true인 경우 최종 SSE 청크는 사용 블록을 전달합니다. |
| stop | string | array | Optional | 정지 시퀀스는 최대 4개입니다. 하나가 생산되자마자 생성이 중단됩니다. |
| tools | array | Optional | 모델이 호출할 수 있는 함수 정의입니다. 아래의 "도구 호출"을 참조하십시오. |
| tool_choice | string | object | Optional | "auto"(기본값), "none" 또는 { type: "function", function: { name } } 특정 호출을 강제 실행합니다. |
| response_format | object | Optional | { type: "json_object" } 모델이 유효한 JSON을 내보내도록 강제합니다. 지원하지 않는 모델의 경우 무시됩니다. |
| reasoning_effort | string | Optional | OpenAI o1/o3 스타일 추론 깊이: "낮음" | "중간" | "높은". "추론과 사고"를 참조하세요. |
| thinking | string | object | Optional | 공급자 간 사고 스위치. "에" | "꺼짐" | "auto" 또는 인류 모양의 { type: "enabled", Budget_tokens: N }. "추론과 사고"를 참조하세요. |
| thinking_budget | integer | Optional | 모델의 추론 추적에 대한 토큰 한도(제공자가 공개하는 경우). |
| ignore_defaults | boolean | Optional | 이 요청에 대해 사용자가 저장한 모델별 기본 매개변수(대시보드에 구성됨)를 건너뜁니다. |
기본 예
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 200,
"temperature": 0.7
}'응답 형태
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional | 안정적인 완료 ID(예: "chatcml-abc123". |
| object | string | Optional | 스트리밍되지 않는 경우 "chat.completion", 스트리밍되는 경우 "chat.completion.chunk"입니다. |
| created | integer | Optional | Unix 타임스탬프(초)입니다. |
| model | string | Optional | 요청된 모델 ID의 에코입니다. |
| choices | array | Optional | 완료 후보 배열: [{ index, message: { role, content, tool_calls? }, 완료_이유 }]. |
| choices[].finish_reason | string | Optional | "그만" | "길이" | "tool_calls" | "콘텐츠_필터". |
| usage | object | Optional | { prompt_tokens, completion_tokens, total_tokens, completion_tokens_details?, prompt_tokens_details?, cache_creation_input_tokens?, cache_creation? }. completion_tokens_details.reasoning_tokens는 모델이 추론 트레이스를 생성했을 때 설정됩니다. 캐시 필드는 upstream이 프롬프트 캐싱 정보를 반환했을 때 나타납니다: prompt_tokens_details.cached_tokens는 캐시 읽기(OpenAI 표준)를 보고하고, cache_creation_input_tokens는 쓰기를 집계하며, cache_creation.ephemeral_5m_input_tokens / ephemeral_1h_input_tokens는 TTL 분할을 제공합니다. |
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1710000000,
"model": "gpt-5.1-chat",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 8,
"total_tokens": 28
}
}추론 및 사고
확장된 추론을 지원하는 모델은 일반 출력과 함께 사고 추적을 노출합니다. Airforce는 세 가지 서로 다른 업스트림 규칙을 어디에서나 작동하는 하나의 표준 매개변수 세트로 정규화합니다.
확인하다 supports_reasoning: true 모델에 GET /v1/models 어떤 ID가 이러한 매개변수를 허용하는지 알아보세요.
추론을 지원하는 모델
…· live정식 매개변수
| Parameter | Type | Required | Description |
|---|---|---|---|
| reasoning_effort | string | Optional | "낮음" | "중간" | "높은". OpenAI o1/o3, GPT-5 추론 모델 및 이에 매핑되는 모든 라우터. |
| thinking | string | object | Optional | "에" | "꺼짐" | 빠른 전환의 경우 "auto", 인류 고유 형태의 경우 { type: "enabled", Budget_tokens: N }. Claude 확장 사고, Gemini 사고 및 DeepSeek 추론에 매핑됩니다. |
| thinking_budget | integer | Optional | 모델이 시각적 출력을 방출하기 전에 추론에 소비할 수 있는 최대 토큰입니다. Budget_tokens를 미러링합니다. |
추론 노력(OpenAI 스타일)
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "o3-mini",
"messages": [{"role": "user", "content": "Prove the Pythagorean theorem."}],
"reasoning_effort": "high"
}'확장된 사고(인류적 스타일)
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Plan a 7-day Italy trip."}],
"thinking": {"type": "enabled", "budget_tokens": 4000}
}'추론 추적 자체는 choices[0].message.reasoning_content (OpenAI 모양) 또는 thinking 블록 content (인류 모양). 추론 토큰은 다음과 같이 청구되고 보고됩니다. usage.completion_tokens_details.reasoning_tokens.
비전 및 이미지 입력
다음을 갖춘 모델 supports_vision: true 콘텐츠 블록으로 삽입된 이미지를 허용합니다. 공개 URL 또는 base64 데이터 URL이 작동합니다. 크기 제한은 업스트림 모델에 따라 다릅니다.
비전 지원 모델
…· livecurl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}}
]
}]
}'도구 호출
다음을 갖춘 모델 supports_tools: true 정의한 함수를 호출할 수 있습니다. 모델은 다음을 반환합니다. tool_calls 정렬; 호출을 실행한 다음 결과를 다시 보냅니다. tool 메시지.
도구 호출 지원 모델
…· live요구
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{"role": "user", "content": "What is the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}],
"tool_choice": "auto"
}'도구 호출로 응답
{
"id": "chatcmpl-abc123",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_1",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Paris\"}"
}
}]
},
"finish_reason": "tool_calls"
}]
}도구 결과에 대한 후속 조치
{
"model": "gpt-5.1-chat",
"messages": [
{"role": "user", "content": "What is the weather in Paris?"},
{
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_1",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"location\":\"Paris\"}"}
}]
},
{"role": "tool", "tool_call_id": "call_1", "content": "{\"temp_c\": 14, \"sky\": \"cloudy\"}"}
]
}스트리밍
세트 stream: true 서버 전송 이벤트로 부분 완료를 수신합니다. 각 이벤트는 스트리밍되지 않는 응답과 동일한 모양을 가진 하나의 JSON 청크입니다. message 로 대체됩니다 delta. 스트림은 다음으로 끝납니다. data: [DONE].
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{"role": "user", "content": "Write a haiku about Berlin."}],
"stream": true,
"stream_options": {"include_usage": true}
}'와이어 형식
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"content":"Cold "},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"content":"stone "},"finish_reason":null}]}
…
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":17,"total_tokens":29}}
data: [DONE]POST /v1/messages
인류와 호환되는 메시지 API. 공무원과 협력 @anthropic-ai/sdk 설정으로 baseURL 에게 https://api.airforce. OpenAI/Google 등으로 전달 Claude가 아닌 모델의 경우 투명하게 표시됩니다.
https://api.airforce/v1/messages요청 본문
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | 모델 ID(인위적 형식 또는 라우팅된 별칭). |
| messages | array | Required | 각 항목: { 역할: "사용자" | "도우미", 내용: 문자열 | 배열 }. |
| max_tokens | integer | Required | Anthropic이 필요합니다. 응답의 토큰 한도입니다. |
| system | string | array | Optional | 시스템 프롬프트. { type: "text", text, 캐시_control? 배열을 전달하세요. } 캐시된 접두사 세그먼트를 표시하는 블록입니다. "프롬프트 캐싱"을 참조하세요. |
| temperature | float | Optional | 0–1. |
| top_p | float | Optional | 핵 샘플링. |
| top_k | integer | Optional | 샘플링 풀을 상위 K 토큰으로 제한합니다. |
| stop_sequences | array | Optional | 정지 시퀀스는 최대 4개입니다. |
| stream | boolean | Optional | true인 경우 Anthropic 스타일 SSE 이벤트 스트림을 내보냅니다("스트리밍" 참조). |
| tools | array | Optional | 인류 도구 정의: { 이름, 설명, input_schema }. 응답에는 tool_use 콘텐츠 블록이 포함될 수 있습니다. |
| tool_choice | object | Optional | { 유형: "자동" | "아무거나" | "도구", 이름? }. |
| thinking | object | Optional | 인류학적 확장된 사고: { type: "enabled", Budget_tokens: N }. |
예
curl https://api.airforce/v1/messages \
-H "x-api-key: sk-air-YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"max_tokens": 256,
"system": "You are a helpful assistant.",
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'응답 형태
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional | 메시지 ID(예: "msg_01ABCxyz". |
| type | string | Optional | 항상 "메시지". |
| role | string | Optional | 항상 "도우미". |
| content | array | Optional | 콘텐츠 블록 배열: { 유형: "텍스트" | "도구_사용" | "생각", … }. |
| model | string | Optional | 요청한 모델의 에코입니다. |
| stop_reason | string | Optional | "끝_턴" | "max_tokens" | "stop_sequence" | "도구_사용". |
| usage | object | Optional | { input_tokens, output_tokens, cache_read_input_tokens?, cache_creation_input_tokens?, cache_creation? }. 캐시 필드는 프롬프트 캐싱이 사용되었을 때 나타납니다. cache_creation.ephemeral_5m_input_tokens 및 ephemeral_1h_input_tokens는 TTL별 쓰기 분할을 제공합니다. |
스트리밍 이벤트
Anthropic SSE는 일회성 JSON 청크 대신 명명된 이벤트를 사용합니다. 각 이벤트에는 event: 이름과 data: JSON 페이로드.
event: message_start
data: {"type":"message_start","message":{"id":"msg_01","role":"assistant","content":[],"model":"claude-sonnet-4.6","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":1}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":17}}
event: message_stop
data: {"type":"message_stop"}프롬프트 캐싱
~에 /v1/messages Claude 모델을 사용하면 다음을 전달하여 접두사를 캐시된 것으로 표시합니다. system 캐시된 세그먼트가 전달되는 블록 배열 cache_control: { type: "ephemeral" }. 동일한 접두사로 시작하는 후속 요청에는 더 저렴한 캐시 읽기 요금이 부과됩니다. 다음을 갖춘 모델 supports_caching: true ~에 /v1/models 이것을 지원하십시오.
신속한 캐싱을 갖춘 모델
…· live{
"model": "claude-sonnet-4.6",
"max_tokens": 1024,
"system": [
{"type": "text", "text": "You are a senior staff engineer at Airforce."},
{
"type": "text",
"text": "<repository-snapshot>...</repository-snapshot>",
"cache_control": {"type": "ephemeral"}
}
],
"messages": [
{"role": "user", "content": "Where is rate limiting enforced?"}
]
}응답에서 캐시 카운트가 보고되는 방식
캐시 토큰 카운트는 각 형식의 네이티브 형태로 전달되므로 SDK(openai, @anthropic-ai/sdk, @google/genai)는 사용자 정의 코드 없이 읽습니다. 값이 0이면 필드가 생략되어 캐시되지 않은 응답을 가볍게 유지합니다.
/v1/chat/completions (OpenAI 형식)
"usage": {
"prompt_tokens": 2104,
"completion_tokens": 147,
"total_tokens": 2251,
"prompt_tokens_details": { "cached_tokens": 1980 },
"cache_creation_input_tokens": 124,
"cache_creation": {
"ephemeral_5m_input_tokens": 124,
"ephemeral_1h_input_tokens": 0
}
}/v1/messages (Anthropic 형식)
"usage": {
"input_tokens": 2104,
"output_tokens": 147,
"cache_read_input_tokens": 1980,
"cache_creation_input_tokens": 124,
"cache_creation": {
"ephemeral_5m_input_tokens": 124,
"ephemeral_1h_input_tokens": 0
}
}/v1beta/.../generateContent (Gemini 형식)
"usageMetadata": {
"promptTokenCount": 2104,
"candidatesTokenCount": 147,
"totalTokenCount": 2251,
"cachedContentTokenCount": 1980
}캐싱이 적용되는 곳
명시적 cache_control 마커는 Claude 모델의 경우 /v1/messages와 /v1/chat/completions에서 적용됩니다 — system 또는 message 콘텐츠 블록에 붙이세요. 다른 많은 제공자(OpenAI 계열, DeepSeek, Gemini)는 자동으로 캐싱합니다. 마커를 보내지 않아도 충분히 긴 프리픽스가 재사용되면 응답에 cached_tokens가 나타납니다.
캐시 유지 시간: 5분 또는 1시간
캐시된 프리픽스는 기본적으로 5분 동안 유지되며 적중할 때마다 타이머가 갱신됩니다. 더 오래 유지하려면 마커에 ttl: "1h" 을(를) 추가하세요. 응답은 각 TTL을 cache_creation 아래에 별도로 보고합니다.
"cache_control": { "type": "ephemeral", "ttl": "1h" }예제: 먼저 쓰기, 다음 읽기
정확히 같은 요청을 두 번 보냅니다(위 캐싱 예제). 프리픽스를 처음 본 호출은 일회성 캐시 쓰기를 지불하고, TTL 이내의 동일한 호출은 훨씬 저렴한 캐시 읽기를 지불합니다.
첫 번째 호출 — 캐시 쓰기(usage 발췌):
"usage": {
"input_tokens": 2104,
"output_tokens": 12,
"cache_creation_input_tokens": 1980,
"cache_read_input_tokens": 0
}TTL 이내의 두 번째 동일 호출 — 캐시 읽기:
"usage": {
"input_tokens": 2104,
"output_tokens": 12,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 1980
}제한 및 비용
- Claude는 최소 캐시 가능 프리픽스(약 1024 토큰, 일부 모델은 더 큼)를 요구합니다. 더 짧은 프리픽스는 캐시되지 않습니다.
- 요청당 최대 4개의 캐시 브레이크포인트가 있으며, 캐시된 프리픽스는 호출 간에 바이트 단위로 동일해야 합니다 — 한 글자만 바뀌어도 캐시를 놓칩니다.
- 캐시 쓰기는 일반 입력보다 비싸고(5m ≈ 1.25×, 1h ≈ 2×) 읽기는 훨씬 저렴합니다(≈ 0.1×). 모델별 캐시 가격은 가격 페이지를 참고하세요.
POST /v1/responses
상태 유지 대화를 위한 OpenAI Responses-API 표면. 동일한 Bearer/x-api-key 인증. 캐시 카운트는 input_tokens_details.cached_tokens(읽기) 및 평면 cache_creation_input_tokens + cache_creation.ephemeral_*(쓰기)로 나타나 /v1/chat/completions와 동등합니다.
https://api.airforce/v1/responses오류
Airforce는 두 끝점 모두에 대해 표준 HTTP 상태 코드와 균일한 오류 봉투를 반환합니다.
| Parameter | Type | Required | Description |
|---|---|---|---|
| 400 | invalid_request | Optional | 잘못된 JSON, 필수 필드 누락, 알 수 없는 모델입니다. |
| 401 | authentication_error | Optional | API 키가 누락되었거나 잘못되었습니다. |
| 403 | permission_error | Optional | 계획 또는 키별 권한은 이 요청을 거부합니다. |
| 429 | rate_limit | Optional | 요청률 또는 일일 토큰 한도를 초과했습니다. |
| 503 | upstream_error | Optional | 요청한 제공업체의 모든 업스트림 키가 실패했습니다. |
{
"error": {
"message": "Model 'gpt-99' not found.",
"type": "invalid_request",
"param": "model",
"code": "model_not_found"
}
}모델 검색
모델 ID의 전체 목록과 해당 기능 플래그(비전, 도구, 추론, 캐싱, 컨텍스트 길이 등)를 확인하세요. /docs/api/models.
curl https://api.airforce/v1/models \
-H "Authorization: Bearer sk-air-YOUR_API_KEY"