본문으로 건너뛰기

개발자

API 레퍼런스

모든 v1 엔드포인트, 요청·응답 필드, Cosvexa 전용 헤더, 오류 코드, 요청 한도.

엔드포인트

메서드와 경로설명
POST /chat/completions스트리밍과 도구 호출을 지원하는 채팅 완성(OpenAI 호환).
POST /chat/stopx-cosvexa-stop-id 헤더로 이름을 붙인 실행 중인 채팅 완성을 중지해요(본문 {"id":"…"}).
POST /followups마지막 대화에 대한 다음 메시지 제안 2–4개.
GET /models워크스페이스에서 쓸 수 있는 모델과 기능, 데이터 정책, 가격.
GET /account워크스페이스와 사용 가능·보류 크레딧.
GET /images/models이미지 생성 모델.
POST /images/generations이미지를 생성해요(base64로 반환되고 라이브러리에도 저장).
POST /images/upscale이미지를 2K 또는 4K로 업스케일해요(생성과 같은 형식으로 반환되고 라이브러리에 저장).
GET /videos/models초당 가격, 해상도, 화면 비율, 길이가 포함된 동영상 모델.
POST /videos동영상 작업을 시작해요. 크레딧은 동영상이 준비되면 청구돼요.
GET /videos/{id}동영상 작업의 상태와 진행률. 완료되면 file_id와 청구된 크레딧도 포함돼요.
GET /videos/{id}/content완성된 MP4.
GET /library라이브러리 항목(이미지, 동영상, 오디오, 문서, 텍스트), 최신순.
GET /library/{id}/content항목의 파일. 텍스트 항목은 Markdown으로 반환돼요.
POST /web/search웹 검색. 제목, URL, 요약 문구를 반환해요.
POST /support키 소유자 이름으로 지원 티켓을 열어요.

Free 키는 /chat/completions(Cosvexa-1), /chat/stop, /models, /account, /web/search, /library, /support를 호출할 수 있어요. /followups, /images, /videos에는 Pro, Team 또는 Enterprise가 필요해요.

POST /chat/completions

필드설명
model필수. 모델 ID 또는 cosvexa-auto.
messages필수. 역할: system, developer (system으로 처리), user, assistant, tool. 내용은 텍스트 또는 text / image_url 파트예요.
stream, stream_options.include_usage서버 전송 이벤트 스트리밍, 마지막 청크에 사용량 포함.
max_tokens / max_completion_tokens최대 출력 토큰이며 모델 한도로 제한돼요. 도구가 포함된 요청의 기본값은 16,000이에요.
temperature0–2.
reasoning_effortlow, medium 또는 high: 모델이 얼마나 생각할지. 사고 설정이 없는 모델은 무시합니다(GET /models의 cosvexa.reasoning_effort). cosvexa-auto에서는 답하는 모델에 전달됩니다. 사고는 출력 토큰으로 과금됩니다.
tools, tool_choice, parallel_tool_calls최대 256개 함수 도구. auto, none, required 또는 특정 함수.

여기에 없는 OpenAI 필드(top_p, stop, n, response_format, seed, logprobs 등)는 오류 없이 무시돼요.

요청 헤더

헤더설명
Authorization: Bearer cvx_...모든 엔드포인트에서 필수.
Idempotency-Key선택 사항이며 1–200자, 워크스페이스 단위로 적용돼요. 전용 GPU 배포에서 제공되는 모델에서는 같은 키와 본문으로 요청을 반복하면 다시 실행하거나 다시 청구하지 않고 첫 번째 답변을 돌려줘요. 같은 키에 다른 본문이면 409 idempotency_key_mismatch, 첫 요청이 아직 실행 중이면 409 request_in_progress, 첫 요청이 실패했으면 409 idempotent_request_failed예요. 다른 모델은 헤더를 받지만 중복 제거는 하지 않아요.
x-cosvexa-stop-id선택 사항: 이 요청에 직접 정한 UUID. 연결을 닫기 전에 {"id":"…"}로 POST /chat/stop을 보내면 사용자가 직접 중지한 것처럼 멈춰요.

응답

json
{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "model": "claude-sonnet-5-5",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "…" }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 12, "completion_tokens": 48, "total_tokens": 60 },
  "cosvexa": { "routed_by": "auto", "data_policy": "provider_retention", "credits_charged": 7200 }
}

단위가 달라요

cosvexa.credits_charged와 오류 세부 정보의 금액은 마이크로 크레딧 단위예요(1 credit = 1,000,000). 예시의 7200은 0.0072크레딧이에요. GET /account는 크레딧 단위로 반환해요.

응답 헤더

x-cosvexa-model (답변한 모델), x-cosvexa-routed-by (user 또는 auto), x-cosvexa-data-policy (self_hosted, no_retention, provider_retention).

Free 키는 /chat/completions와 /web/search에서 x-cosvexa-free-remaining(오늘 남은 무료 질문 수)과 x-cosvexa-free-resets-at(갱신 시각, ISO 8601)도 받아요.

스트리밍

stream: true를 쓰면 답변이 chat.completion.chunk 이벤트로 도착하고, 텍스트는 choices[0].delta.content에 있어요. 도구 호출은 index로 구분되는 delta.tool_calls 조각으로 도착해요. 각 호출의 첫 조각에는 id, type, function.name이 있고, 이후 조각은 function.arguments에 이어 붙어요. 마지막 청크에는 finish_reason(stop, length 또는 tool_calls)이 있어요.

text
data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_1","type":"function","function":{"name":"get_weather","arguments":""}}]},"finish_reason":null}]}

data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"city\":\"Istanbul\"}"}}]},"finish_reason":null}]}

data: {"choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}

data: {"choices":[],"usage":{"prompt_tokens":40,"completion_tokens":12,"total_tokens":52},"cosvexa":{"routed_by":"user","data_policy":"no_retention","credits_charged":1800}}

data: [DONE]

크레딧은 마지막 사용량 청크에만 나와요. stream_options.include_usage를 쓰면 [DONE] 직전의 마지막 청크에 choices: [], usage, cosvexa.credits_charged(마이크로 크레딧)가 있어요. 쓰지 않으면 스트림은 요청 비용을 알려 주지 않아요.

스트림 중 발생한 오류(HTTP 상태는 이미 200)는 오류의 실제 status, type, code를 담은 이벤트 하나로 전송되고, 그 뒤에 [DONE]이 와요.

text
data: {"error":{"message":"The model rejected the request. Check the messages, tools (JSON schemas, tool_call_id) and parameters.","type":"invalid_request_error","code":"provider_bad_request","status":400}}

data: [DONE]

type, code, status는 같은 코드의 비스트리밍 오류와 같아요(아래 오류 참고). 4xx는 그대로 다시 시도하지 말고, 5xx는 다시 시도할 수 있어요.

GET /models

OpenAI 형식의 목록을 반환해요. 각 항목의 cosvexa 필드에는 display_name, family, capabilities, data_policy, context_window, pricing(입력/출력 100만 토큰당 크레딧)이 있어요. 입력이 long_context.over_input_tokens를 넘으면 요청 전체가 긴 컨텍스트 요금으로 청구돼요. 가상 항목 cosvexa-auto가 맨 앞에 나와요.

POST /images/generations

bash
curl https://cosvexa.ai/api/v1/images/generations \
  -H "Authorization: Bearer $COSVEXA_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt":"a lighthouse at dusk","size":"1024x1024","n":1}'

필드: prompt (1–4,000자), model (비워 두거나 auto = 자동), size, n (1–4). 응답에는 data[].b64_json, mime_type, file_id가 포함돼요. 플랜에 Studio 이미지가 포함되어 있어야 해요.

POST /images/upscale: file_id(워크스페이스의 이미지) 또는 image(base64 또는 data URL, PNG·JPEG·WebP 최대 10 MB), target(긴 변 기준 2k = 2048 px 또는 4k = 4096 px, 각각 가격이 달라요), 선택 사항인 model. 응답은 생성과 같은 형식이며, 둘은 한도 하나를 공유해요.

필드: query (1–400자), max_results (1–10, 기본 5), news. 별도로 청구되지 않아요. 엄격한 개인정보 보호를 강제하는 워크스페이스는 403 privacy_blocked를 받아요. 작업을 수행하는 모델을 model로 보내세요. cosvexa-1이거나 model이 없으면 Cosvexa 자체 검색이 먼저 실행되고, 아무것도 찾지 못하거나 실패하면 예비 검색 제공업체가 응답하며 이 제공업체는 검색어만 받아요. 엄격한 개인정보 보호에서는 예비 검색을 사용하지 않아요. 503 search_unavailable은 어떤 검색 제공업체도 응답하지 못했을 때만 반환돼요.

Free 키도 Free 채팅의 Cosvexa-1과 같은 조건(위 참고)으로 검색할 수 있어요. 호출마다 그날의 무료 질문 50개 중 하나로 계산되고, 아무것도 찾지 못했거나 검색이 실패하면 돌려받아요. cosvexa-1이나 cosvexa-auto가 아닌 model은 402 plan_required예요.

POST /followups

필드: messages(대화, 메시지 1–500개. 마지막 사용자 메시지와 그 뒤의 답변이 사용돼요), surface(chat 또는 code), kind, model(답변한 모델. 없거나 cosvexa-1이면 Cosvexa-1이 제안을 작성해요), locale, privacy_mode. 응답은 {"object":"followups","followups":[…],"cosvexa":{"credits_charged":…}}이고, 소형 모델의 실제 비용으로 청구돼요. /chat/completions에서 followups: true를 쓰면 대신 답변과 함께 반환돼요.

동영상

GET /videos/models는 동영상 모델을 credits_per_second, resolutions, aspects, min_seconds, max_seconds, 각 모델의 supports와 함께 보여 줘요. POST /videos는 prompt(1–4,000자), model, seconds, aspect(모델이 지원하는 경우 16:9, 9:16, 1:1, 21:9), resolution(기본값 720p 또는 1080p), audio, start_image_file_id, end_image_file_id, extend_file_id를 받고, 작업 id와 함께 202로 응답해요. GET /videos/{id}를 폴링하세요(queued, running, succeeded, failed 또는 canceled, progress 포함). succeeded가 되면 GET /videos/{id}/content가 MP4를 반환해요(그 전에는 409 not_ready). 크레딧은 동영상이 준비되면 청구돼요. 플랜에 Studio 동영상이 포함되어 있어야 해요.

GET /library

쿼리: kind(image, video, audio, document 또는 text), q(제목이나 프롬프트와 일치), after와 before(ISO 날짜), limit(1–100, 기본 30). data의 각 항목에는 id, kind, title, prompt, model, created_at, mime, size_bytes, file_name, seconds, aspect가 있어요. GET /library/{id}/content는 항목의 파일을 반환해요. 키 소유자가 읽을 수 없는 파일은 숨겨져요.

POST /support

필드: subject(3–200자), body(5–10,000자), category(general, billing, models, account, bug, api 또는 other), priority(low, normal 또는 high). 티켓의 id, subject, status와 함께 201로 응답해요. 한 사람이 열어 둘 수 있는 티켓은 최대 20개예요.

오류

json
{ "error": { "message": "…", "type": "insufficient_quota", "code": "insufficient_credits", "details": { "needed": 12000000, "available": 3000000 } } }
상태코드해결 방법
400validation, capability_unsupported요청을 수정하세요. 예: 도구를 지원하는 모델 고르기.
400provider_bad_request모델이 요청을 거부했어요. 메시지, 도구의 JSON 스키마, tool_call_id 값을 확인하세요. 그대로 다시 시도하지 마세요.
401invalid_api_key키를 확인하세요. 폐기되었을 수 있어요.
402insufficient_credits, budget_exceeded결제에서 크레딧을 추가하세요.
402free_daily_exhaustedFree: 오늘의 Cosvexa-1 질문 50개를 모두 썼어요. details.resetsAt에 갱신되며, 플랜을 이용하면 지금 바로 계속할 수 있어요.
402plan_requiredFree: Cosvexa-1만 답변해요(cosvexa-1 또는 cosvexa-auto). details.plansUrl에 플랜 링크가 있어요.
403plan_required, privacy_blocked, forbidden플랜을 업그레이드하거나 개인정보 보호 설정을 충족하는 모델을 고르세요.
403third_party_blockedCosvexa-1 작업은 다른 제공업체로 보내지 않는데, 이 요청에는 필요했어요. 다른 모델이나 cosvexa-auto를 고르세요.
403email_unverifiedFree: 일일 질문을 쓰려면 키 소유자가 이메일 주소를 인증해야 해요.
404model_not_foundGET /models의 ID를 쓰세요.
409idempotency_key_mismatch, request_in_progress다른 본문으로 같은 Idempotency-Key를 재사용하지 마세요.
409idempotent_request_failed이 Idempotency-Key로 처음 보낸 요청이 실패했어요. 새 키로 다시 시도하세요.
409not_ready동영상이 아직 완성되지 않았어요. GET /videos/{id}를 폴링하세요.
429rate_limited, capacity_exhaustedRetry-After 헤더의 초만큼 기다리세요.
499canceled요청이 끝나기 전에 중지됐어요(POST /chat/stop).
5xxmodel_unavailable, no_model_available, internal잠시 후 다시 시도하거나 다른 모델을 고르세요.
503model_maintenance모델이 점검 중이에요. 다른 모델이나 cosvexa-auto를 고르세요.
504model_warming_timeout모델 서버가 시작 중이었는데 제시간에 준비되지 않았어요. 1분 후에 다시 시도하세요.

요청 한도

범위한도
모든 v1 호출 (워크스페이스당)Pro 60/분, Team 300/분
Free 키 (1인당)Free 키가 호출할 수 있는 모든 엔드포인트 합산 10/분
1인당 (선택)계약으로 정해지며, 워크스페이스 한도보다 먼저 확인돼요
POST /images/generations키당 10/분
POST /images/upscale/images/generations의 키당 10/분을 공유
POST /followups키당 60/분
POST /web/search키당 30/분
POST /videos키당 5/분
POST /support키당 10분에 5회

GET /models와 GET /account를 포함한 모든 호출이 워크스페이스 한도에 포함돼요(Free에서는 1인당 한도). 한도를 넘으면 Retry-After 헤더와 함께 429 rate_limited가 반환돼요.

아직 지원하지 않음

/responses, Anthropic /messages, /embeddings, 오디오(TTS/STT), /completions, 모더레이션 엔드포인트, 웹훅, 키별 범위나 지출 한도는 아직 제공되지 않아요.