쿠키를 사용합니다. 쿠키와 브라우저 저장소는 로그인 상태를 유지하고 환경설정을 기억합니다. 동의하시면 사이트 이용 방식도 측정합니다. 언제든지 할 수 있습니다. 자세한 내용은 쿠키 정책을 참고하세요.

Chat Completions

엔드포인트

Chat Completions

POST /chat/completions 하나로 모든 텍스트 모델을 OpenAI 채팅 형식으로 호출하는 방법을 설명합니다. 요청 파라미터, 응답 구조, 결제 관련 참고 사항, 오류 처리를 정리했습니다. 모든 모델에 같은 요청 형식이 적용됩니다.

플레이그라운드에서 사용해 보기

Chat Completions 엔드포인트는 OpenAI 채팅 형식을 사용하며 GPT, Claude, Gemini, Llama, DeepSeek, Mistral을 비롯해 카탈로그에 있는 수백 개의 텍스트 모델 모두에서 동작합니다. 요청 본문은 변경 없이 업스트림 제공업체로 전달됩니다. api14는 키, 모델, 한도, 잔액만 확인하고 요청이 끝나면 사용량을 기록합니다.

POST https://api14.com/api/v1/chat/completions
Authorization: Bearer sk-api14-...
Content-Type: application/json

요청

파라미터타입설명
modelstring, 필수모델 ID. 예: anthropic/claude-sonnet-4.5. :online이나 :nitro 같은 변형도 사용할 수 있습니다. 모델 ID를 참고하세요.
messagesarray, 필수{ role, content } 객체로 이루어진 대화. 역할: system, developer, user, assistant, tool.
modelsstring[]첫 번째 모델이 실패할 경우 순서대로 시도할 폴백 모델. 제공업체 라우팅을 참고하세요.
streamboolean토큰을 Server-Sent Events로 스트리밍합니다. 스트리밍을 참고하세요.
max_tokens / max_completion_tokensinteger생성 토큰 수의 상한.
temperaturenumber샘플링 온도. 보통 0–2.
top_p, top_k, min_p, top_anumber기타 샘플링 제어. 지원하지 않는 모델에서는 무시됩니다.
frequency_penalty, presence_penalty, repetition_penaltynumber반복 제어.
stopstring | string[]중지 시퀀스.
seedinteger최선의 노력 기반 결정론적 샘플링.
logprobs, top_logprobsboolean, integer모델이 지원하는 경우 토큰 로그 확률을 반환합니다.
tools, tool_choice, parallel_tool_calls함수 호출. 도구 호출을 참고하세요.
response_formatobjectJSON 모드 또는 JSON Schema 출력. 구조화된 출력을 참고하세요.
reasoning, include_reasoningobject, boolean사고 제어. 추론을 참고하세요.
plugins, web_search_options웹 검색. 웹 검색을 참고하세요.
providerobject업스트림 제공업체 선호 설정. 제공업체 라우팅을 참고하세요.
modalitiesstring[]예: 이미지 출력에는 ["image", "text"], 오디오 출력에는 ["text", "audio"].
predictionobject예측 출력({ type: "content", content }). 편집 시 지연 시간을 줄여 줍니다.
transformsstring[]예: ["middle-out"]으로 컨텍스트 윈도를 초과하는 프롬프트를 압축합니다.
userstring자체 최종 사용자 식별자.

메시지 content는 문자열이거나 콘텐츠 파트(text, image_url, file, input_audio)의 배열일 수 있습니다. 비전 및 파일을 참고하세요.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api14.com/api/v1",
  apiKey: process.env.API14_API_KEY,
});

const result = await client.chat.completions.create({
  "model": "openai/gpt-5-mini",
  "messages": [
    {
      "role": "user",
      "content": "Explain vector databases in two sentences."
    }
  ]
});
console.log(result.choices[0].message.content);

응답

{
  "id": "gen-1760000000-abc123",
  "object": "chat.completion",
  "created": 1760000000,
  "model": "anthropic/claude-sonnet-4.5",
  "provider": "Anthropic",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": { "role": "assistant", "content": "Hello! How can I help you today?" }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 0 },
    "cost": 0.000171
  }
}

usage.cost는 USD로 표시된 요청 비용입니다. api14는 요청이 끝난 뒤 이 금액을 잔액에서 차감합니다. id는 생성 ID로, 나중에 생성 내역 조회에서 확인할 수 있습니다.

결제 관련 참고 사항

  • 모델의 게시된 가격을 지불하며, 청구 금액은 usage.cost로 반환됩니다. 요금 및 결제를 참고하세요.
  • 실패한 요청(4xx 또는 5xx 상태)에는 요금이 부과되지 않습니다.
  • 요청에 models: [...]가 포함된 경우 모든 폴백 모델이 키와 요금제에서 허용되어야 합니다. 그렇지 않으면 게이트웨이가 업스트림으로 보내기 전에 요청을 거부합니다.

오류

상태코드발생 조건
400model_requiredmodel이 없습니다.
400invalid_json본문이 JSON 객체가 아닙니다.
401invalid_api_key키가 없거나, 유효하지 않거나, 폐기되었습니다.
402insufficient_balanceUSD 잔액이 $0입니다.
403model_not_allowed / plan_required키의 허용 목록이나 요금제가 이 모델을 지원하지 않습니다.
404model_not_found알 수 없거나 비활성화된 모델 ID입니다.
413payload_too_large요청 본문이 25 MB를 초과합니다.
429rate_limited / daily_limit_reachedRPM 한도 또는 키의 일일 USD 한도에 도달했습니다.
502upstream_unavailable업스트림 제공업체에 연결할 수 없습니다.

컨텍스트 길이 초과나 콘텐츠 모더레이션 같은 업스트림 오류는 원래 상태 코드와 동일한 오류 형식으로 반환됩니다. 오류를 참고하세요.