POST /completions
레거시 텍스트 완성
메시지 배열 대신 하나의 프롬프트 문자열을 받는 구형 인터페이스입니다. OpenAI 의 legacy completions 형상을 그대로 씁니다.
POST https://openrouter.myip.co.kr/api/v1/completions인증
추론 키(sk-mo-v1-)가 필요합니다. 관리 키로 부르면 401 invalid_api_key 입니다.
요청 파라미터
promptstring | string[]필수프롬프트. 문자열 배열이면 \n 으로 이어 붙여 한 건의 user 메시지로 만듭니다. 문자열도 문자열 배열도 아니면 400 invalid_request 입니다.
modelstring모델 id. 생략하면 서비스 기본 모델을 씁니다.
modelsstring[]후보 체인. /chat/completions 와 같습니다.
providerobjectprovider 선택 규칙. /chat/completions 와 같습니다.
streambooleantrue 면 SSE 로 응답합니다.
max_tokensinteger생성할 최대 토큰 수.
temperaturenumber0.0–2.0.
stopstring | string[]생성을 멈출 문자열.
샘플링 파라미터는 요청 파라미터의 목록이 그대로 적용됩니다. messages 를 보내도 무시되고 prompt 만 읽습니다.
요청 예제
curl https://openrouter.myip.co.kr/api/v1/completions \
-H "Authorization: Bearer $MYIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "lgai/exaone-4.0-32b",
"prompt": "다음 문장을 영어로 옮겨라: 오늘 서울은 맑고 바람이 분다.",
"max_tokens": 64,
"temperature": 0.2
}'응답
idstringgen- 으로 시작하는 generation id. X-MyIP-Generation-Id 헤더와 같습니다.
objectstring항상 "text_completion" 입니다. 스트리밍 청크도 같은 값을 씁니다.
createdinteger유닉스 초.
modelstring실제로 응답한 모델 id.
providerstring실제로 응답한 provider 표시명.
choicesobject[]각 항목은 index, text, finish_reason, logprobs 를 갖습니다. message 필드는 없습니다 — chat 응답을 text 형식으로 되돌린 결과입니다. 업스트림이 native_finish_reason 을 주면 그 필드도 함께 옵니다.
choices[].logprobsnull항상 null 입니다. 로그 확률은 지원하지 않습니다.
usageobjectprompt_tokens, completion_tokens, total_tokens, 그리고 KRW 청구액인 cost 와 cost_details. /chat/completions 와 같습니다.
응답 예제
{
"id": "gen-4mVpQz8LrXtB6nKwYsHdE2cJf9",
"object": "text_completion",
"created": 1788452411,
"model": "lgai/exaone-4.0-32b",
"provider": "MyIP Local GPU",
"choices": [
{
"index": 0,
"text": " Seoul is clear and windy today.",
"finish_reason": "stop",
"logprobs": null,
"native_finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 9,
"total_tokens": 40,
"cost": 0.002280,
"cost_details": { "upstream_inference_cost": 0.000437 }
}
}응답 헤더는 /chat/completions 와 같습니다. 비스트리밍이면 X-MyIP-Cost-KRW 와 X-MyIP-Credit-Balance 가 붙습니다.
스트리밍
curl -N https://openrouter.myip.co.kr/api/v1/completions \
-H "Authorization: Bearer $MYIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "lgai/exaone-4.0-32b",
"prompt": "하나부터 셋까지 세어봐.",
"stream": true,
"max_tokens": 24
}'data: {"id":"gen-4mV…","object":"text_completion","created":1788452411,"model":"lgai/exaone-4.0-32b","provider":"MyIP Local GPU","choices":[{"index":0,"text":"하나","finish_reason":null,"logprobs":null}]}
data: {"id":"gen-4mV…","object":"text_completion","created":1788452411,"model":"lgai/exaone-4.0-32b","provider":"MyIP Local GPU","choices":[{"index":0,"text":", 둘","finish_reason":null,"logprobs":null}]}
data: {"id":"gen-4mV…","object":"text_completion","created":1788452412,"model":"lgai/exaone-4.0-32b","provider":"MyIP Local GPU","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":8,"total_tokens":22,"cost":0.001620,"cost_details":{"upstream_inference_cost":0.000312}}}
data: [DONE]델타가 delta.content 가 아니라 choices[].text 로 온다는 점만 다르고, usage 청크와 [DONE] 종결은 스트리밍과 같습니다.
사용 기록에서의 표시
이 경로로 만든 요청도 GET /generation으로 조회할 수 있습니다. api_type 필드는 /chat/completions 와 마찬가지로 "chat" 으로 기록됩니다 — 내부적으로 같은 파이프라인을 쓰기 때문입니다.
오류
| 상태 | error_type | 발생 조건 |
|---|---|---|
| 400 | invalid_request | 본문이 JSON 객체가 아님, prompt 누락, prompt 가 문자열도 문자열 배열도 아님 |
| 400 | model_not_found | 모르는 model, 또는 models[] 가 전부 모르는 id |
| 401 | invalid_api_key | 키 없음·폐기·헤더 없음·관리 키 사용 |
| 401 | expired_api_key | 만료된 키 |
| 402 | insufficient_credits | 잔액 부족 또는 잔액 부족으로 정지된 키 |
| 402 | key_limit_exceeded | 키 사용 한도 초과 |
| 403 | key_suspended | 관리자가 정지한 키 |
| 404 | no_endpoints_found | 후보 체인이 빔 |
| 408 | timeout | 업스트림 응답 지연 |
| 429 | rate_limit_exceeded | 요청 빈도 제한 초과 |
| 502 | provider_error | 모든 후보 실패 |
| 503 | model_loading | 로컬 슬롯 기동 실패 |
| 500 | server | 그 밖의 서버 오류 |
자세한 처리는 오류와 디버깅에 있습니다.
마지막 수정 2026. 9. 5.