API 미리보기
기존 코드에 바로 붙여 쓰세요
Bearer Token 하나면 어디서든 내 로컬 LLM을 호출할 수 있습니다.
클라우드 LLM API와 동일한 방식으로 교체 가능합니다.
{chatId}로
대화 세션을 식별하며, 이력은 서버에서 관리됩니다 — 매 요청마다 전체 컨텍스트를 재전송할 필요가 없습니다.
# POST — 메시지 전송
POST https://api-xxxxx.cortexable.com/v1/{chatId}/message
Authorization: Bearer <your-token>
Content-Type: application/json
{
"model": "llama3-8b",
"message": "안녕하세요!",
"stream": true
}
# 응답 (SSE 스트리밍)
data: {"token": "안녕", "done": false}
data: {"token": "하세요!", "done": false}
data: {"token": "", "done": true}
# curl — 바로 실행해보기 (단답)
curl -X POST \
https://api-xxxxx.cortexable.com/v1/{chatId}/message \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{"model":"llama3-8b","message":"안녕하세요!","stream":false}'
# curl — SSE 스트리밍 수신
curl -X POST \
https://api-xxxxx.cortexable.com/v1/{chatId}/message \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"model":"llama3-8b","message":"안녕하세요!","stream":true}' \
--no-buffer
import requests
url = "https://api-xxxxx.cortexable.com/v1/{chatId}/message"
headers = {
"Authorization": "Bearer <your-token>",
"Content-Type": "application/json"
}
payload = {
"model": "llama3-8b",
"message": "안녕하세요!",
"stream": False
}
res = requests.post(url, headers=headers, json=payload)
print(res.json())
// fetch API — 브라우저 · Node.js 18+
const res = await fetch(
"https://api-xxxxx.cortexable.com/v1/{chatId}/message",
{
method: "POST",
headers: {
"Authorization": "Bearer <your-token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "llama3-8b",
message: "안녕하세요!",
stream: false
})
}
);
const data = await res.json();
console.log(data);
// Java 11+ HttpClient
import java.net.http.*;
import java.net.URI;
var client = HttpClient.newHttpClient();
var body = """
{"model":"llama3-8b","message":"안녕하세요!","stream":false}""";
var request = HttpRequest.newBuilder()
.uri(URI.create(
"https://api-xxxxx.cortexable.com/v1/{chatId}/message"))
.header("Authorization", "Bearer <your-token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload, _ := json.Marshal(map[string]any{
"model": "llama3-8b",
"message": "안녕하세요!",
"stream": false,
})
req, _ := http.NewRequest("POST",
"https://api-xxxxx.cortexable.com/v1/{chatId}/message",
bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer <your-token>")
req.Header.Set("Content-Type", "application/json")
resp, _ := (&http.Client{}).Do(req)
defer resp.Body.Close()
fmt.Println(resp.Status)
}
// .NET 6+
using System.Net.Http;
using System.Net.Http.Json;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add(
"Authorization", "Bearer <your-token>");
var res = await client.PostAsJsonAsync(
"https://api-xxxxx.cortexable.com/v1/{chatId}/message",
new {
model = "llama3-8b",
message = "안녕하세요!",
stream = false
});
Console.WriteLine(await res.Content.ReadAsStringAsync());