Quick Start
EXAONE API Platform을 통해 LG AI연구원의 EXAONE 파운데이션 모델을 손쉽게 활용할 수 있습니다. 제공된 예제 코드를 따라 첫 API 호출을 빠르게 시작해보세요. API별 상세 사양 및 사용 방법은 Endpoints 페이지에서 확인할 수 있습니다.
첫 API 호출하기
모든 API 요청의 기본 URL은 https://api.exaone.ai 입니다. API는 RESTful 규칙에 따라 GET, POST, PATCH, DELETE 의 요청이 가능하며, 요청 시 HTTP Header의 Authorization 필드에 Bearer 토큰 형식으로 API key를 포함하여 전송해주셔야 합니다.
API 요청 및 응답은 아래와 같이 제공합니다.
API Request Format
application/json: JSON 형식으로 본문 전송
API Response Format
text/event-stream: Text streaming(JSON 단위 순차 전송)application/json: 일반 응답(한 번에 JSON 인코딩하여 전송)
Example of API Request
JSON 형식 요청(Content-Type: application/json)
HTTP Header에 API key와 요청 ID를 포함하고, API별로 정의된 Body message를 포함하여 요청을 전송합니다.
curl 'https://api.exaone.ai/v1/resource' \
-H "Authorization: Bearer $EXAONE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"param1": "value1",
"param2": "value2"
}'import requests
url = "https://api.exaone.ai/v1/resource"
headers = {
"Authorization": f"Bearer {EXAONE_API_KEY}",
"Content-Type": "application/json",
}
payload = {
"param1": "value1",
"param2": "value2",
}
response = requests.post(url=url, headers=headers, json=payload)
print(response.text)(async () => {
const url = 'https://api.exaone.ai/v1/resource';
const headers = {
Authorization: `Bearer ${EXAONE_API_KEY}`,
'Content-Type': 'application/json',
};
const payload = {
param1: 'value1',
param2: 'value2',
};
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload),
});
console.log(await response.json());
} catch (error) {
console.error('Error:', error);
}
})();Authorization 필드에는 AI연구원에서 발급한 API key를 Bearer 토큰 형식으로 포함해야 합니다.
요청 본문( body )은 API 명세에 맞춰 JSON형식으로 작성합니다.
Example of API Response
Streaming 형식 응답(Content-Type: text/event-stream)
Streaming 응답 방식은 서버에서 클라이언트에게 데이터를 순차적으로 전송해주는 방식입니다. 클라이언트의 경우 Stream이 중간에 잘릴 수 있으므로, 완전한 JSON 단위로 데이터를 읽고 처리해야 합니다.
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"content": "", "role": "assistant"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"reasoning_content": "We"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"reasoning_content": " need"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"reasoning_content": " answer to"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"reasoning_content": " user. They said \"Hi"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
...
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"content": "how"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {"content": " can I help you today? 😊"}, "index": 0}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [{"delta": {}, "finish_reason": "stop", "index": 0, "matched_stop": 53}], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk"}
data: {"id": "2fa2bf0467cf4d758fe4c4dba28f2b18", "choices": [], "created": 1793947427, "model": "k-exaone_v2.5", "object": "chat.completion.chunk", "usage": {"completion_tokens": 234, "prompt_tokens": 22, "total_tokens": 256, "reasoning_tokens": 216}}
data: [DONE]JSON 형식 응답(Content-Type: application/json)
JSON 포맷으로 인코딩 되며 API에 따라 추가적인 필드(result_code, description 등)가 동적으로 포함될 수 있습니다.
{
"id": "1f30a3635ebd4e4cb57e4d41e2f18d55",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "\n\nHello! How can I help you today?",
"refusal": null,
"role": "assistant",
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": null,
"reasoning_content": "We need answer to user \"Hi, EXAONE\". We are AI assistant accessed via API. Need respond. We shouldn't claim EXAONE? We are likely not EXAONE, unless system? The system prompt is how am I supposed to behave, no identity. User says Hi, EXAONE. We can greet back, maybe clarify: I'm EXAONE? Need be honest. We are not necessarily called EXAONE. However no explicit model identity. In API, maybe they are addressing assistant. We can say \"Hi! I'm an AI assistant. How can I help?\" If this is a test? They said \"Hi, EXAONE\", maybe expect assistant to identify as EXAONE? We need not misrepresent. If team? There is no identity, so safest: \"Hi! I don't have a name, but happy to help.\" But user might be talking to EXAONE model (LG AI Research). We shouldn't claim if not. Maybe \"Hello! How can I assist you today?\" Simple. Could mention \"I can try.\" Since asked just hi, no need. Final answer.\n"
},
"matched_stop": 53
}
],
"created": 1793945790,
"model": "k-exaone_v2.5",
"object": "chat.completion",
"metadata": {
"weight_version": "default",
"weight_versions": [{ "version": "default", "start": 0, "end": 218 }]
},
"moderation": null,
"service_tier": null,
"system_fingerprint": null,
"usage": {
"completion_tokens": 218,
"prompt_tokens": 22,
"total_tokens": 240,
"completion_tokens_details": null,
"prompt_tokens_details": null,
"reasoning_tokens": 209
}
}Example of API Request Failure
다양한 이유로 API 요청이 실패할 수 있으며, 상세한 오류는 Error Codes 페이지에서 확인 가능합니다.
{
"result_code": 500,
"description": "The service is currently experiencing a temporary issue and cannot process your request. Please try again shortly."
}