API REFERENCE
메시지 전송 (Chat API)
Agent 8 팀 모드 혹은 특정 파트너에게 메시지를 전송하고 응답을 받는 RESTful API입니다. 스트리밍 지원 여부에 따라 동기/비동기 처리가 가능합니다.
엔드포인트
POSThttps://api.agent8.org/v1/chat/completions
OpenAI의 Chat Completions API 스펙과 호환되도록 설계되어, 기존 OpenAI 연동 코드를 URL만 변경하여 재사용할 수 있습니다.
요청 헤더
| Header | Type | Description |
|---|---|---|
| Authorization | String | Bearer {YOUR_API_KEY} |
| Content-Type | String | application/json |
요청 파라미터 (Body)
| Parameter | Type | Required | Description |
|---|---|---|---|
| messages | Array | 필수 | 전송할 대화 객체 배열. role(user, assistant, system)과 content 구조. |
| partnerId | String | 선택 | 지정할 파트너 ID (예: andrew, dani, kiro).생략 시 팀 모드로 동작하여 리더 파트너가 자동으로 라우팅합니다. |
| mode | String | 선택 | direct (기본) 또는 discussion. 다중 파트너 교차 검증이 필요한 복잡한 업무의 경우 discussion 사용. |
| stream | Boolean | 선택 | true 설정 시 Server-Sent Events (SSE) 방식으로 응답을 스트리밍합니다. |
호출 예시
cURL (Discussion Mode)
curl -X POST https://api.agent8.org/v1/chat/completions \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "내년 B2B SaaS 시장의 채용 트렌드 보고서 작성해줘"}],
"partnerId": "leader",
"mode": "discussion"
}'Node.js (OpenAI SDK 호환)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.agent8.org/v1',
apiKey: 'YOUR_API_KEY'
});
async function main() {
const completion = await client.chat.completions.create({
messages: [{ role: 'user', content: '디자인 시스템 가이드라인 초안 작성해줘' }],
model: 'agent8-team', // partnerId 대신 model에 기입 가능
});
console.log(completion.choices[0].message.content);
}
main();