테마 전환

이 편은 앞선 개념·메뉴얼 편에서 다룬 내용으로 만든 복사용 예제 모음입니다. 기본 주소는 http://127.0.0.1:8080, 키를 설정했다면 Authorization: Bearer <키> 헤더를 추가하세요. 모델 이름은 /v1/models가 알려 주는 로드된 모델 ID(문서 예제에서는 strata)를 사용합니다.
가장 기본적인 서버 연결 확인
sh
curl http://127.0.0.1:8080/health
curl http://127.0.0.1:8080/v1/models -H "Authorization: Bearer <키>"/health가 답하지 않으면 strata launch --status로 시작 여부부터 확인합니다. 시작에 시간이 걸리는 큰 모델도 있으니 로그(launch 모니터 6번 뷰)를 함께 보세요.
실제 채팅 요청 보내기: curl과 OpenAI SDK
sh
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" \
-d '{"model": "strata", "messages": [{"role": "user", "content": "GPU에 관한 한글 구절 하나."}], "max_tokens": 512}'python
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="none")
r = client.chat.completions.create(
model="strata",
messages=[{"role": "user", "content": "Hello!"}],
)
print(r.choices[0].message.content)스트리밍은 OpenAI 표준대로 "stream": true를 넣으면 SSE로 옵니다. 생성 파라미터는 temperature, top_p, top_k, min_p, seed, stop/stop_sequences, logit_bias가 요청별로 반영됩니다.
Anthropic Messages API
Claude Code 같은 Anthropic 프로토콜 클라이언트는 base URL을 루트로 두고 /v1/messages를 호출합니다.
sh
curl -X POST http://127.0.0.1:8080/v1/messages \
-H "Content-Type: application/json" -H "x-api-key: <키>" -H "anthropic-version: 2023-06-01" \
-d '{"model": "strata", "max_tokens": 256, "messages": [{"role": "user", "content": "Hello!"}]}'도구 사용(tool_use/tool_result)과 스트리밍을 지원하고, thinking 블록도 Anthropic 형식으로 나옵니다.
사고 과정(Thinking) 조절과 스트리밍
OpenAI 엔드포인트에서 reasoning 양을 조절합니다.
sh
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "strata",
"messages": [{"role": "user", "content": "이 코드의 버그를 찾아줘."}],
"reasoning_effort": "low"
}'"reasoning": {"effort": "..."} 또는 완전 차단용 "chat_template_kwargs": {"enable_thinking": false}도 동작합니다. 스트리밍 시 사고 내용은 OpenAI 스트림에서 reasoning_content 필드로, Anthropic에서는 thinking 블록으로 흐릅니다.
JSON/스키마 출력
sh
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "strata",
"messages": [{"role": "user", "content": "이력서에서 이름을 뽑아줘"}],
"response_format": {"type": "json_schema", "json_schema": {
"name": "resume", "schema": {"type": "object", "properties": {"name": {"type": "string"}}}
}}
}'최상위 루트는 객체여야 하고, 서버는 생성된 답을 검증해 잘못된 JSON이면 502 structured_output_failed를 돌려줍니다. 도구·MCP와 JSON 포맷을 동시에 쓰면 거부됩니다. LaTeX(\alpha 같은)가 섞인 답이 JSON 이스케이프를 깨뜨릴 수 있는 환경에서는 response_format에 "repair_latex_escapes": true를 넣을 수 있습니다.
상태와 슬롯, 메트릭 조회
sh
curl http://127.0.0.1:8080/status # 서버 상태 요약
curl http://127.0.0.1:8080/slots # 슬롯별 busy/idle, n_prompt_tokens
curl http://127.0.0.1:8080/metrics # 모니터가 읽는 JSON 스냅샷
curl http://127.0.0.1:8080/props # 채팅 템플릿·컨텍스트 한도·엔진 버전Prometheus로 붙이려면 Accept 헤더를 바꾸기만 하면 됩니다. vLLM 지표 이름을 쓰므로 기존 대시보드가 그대로 동작합니다.
sh
curl -H "Accept: text/plain" http://127.0.0.1:8080/metricsdocs/monitoring/의 prometheus.yml, grafana-strata.json을 바로 쓸 수 있고, 키가 있으면 스크레이퍼가 bearer token을 보냅니다.
대화 세션 저장과 복원
엔진에 붙어 있는 대화를 파일로 남겨 재시작 후에도 같은 대화를 계속할 수 있습니다(같은 엔진 버전에서). 먼저 서버 설정에 저장 폴더를 지정합니다(--slot-save-path DIR 또는 설정의 "slot_save_path").
sh
curl -X POST "http://127.0.0.1:8080/slots/0?action=save" \
-H "Content-Type: application/json" -d '{"filename": "chat1.bin"}'
curl -X POST "http://127.0.0.1:8080/slots/0?action=restore" \
-H "Content-Type: application/json" -d '{"filename": "chat1.bin"}'파일은 대화 기록 내보내기(export)가 아니라 엔진 상태와 토큰 정체성이고 큽니다(63K 토큰 대화당 약 1.2GB). 파일명은 저장 폴더 안의 평범한 이름만 허용되고, 저장은 --session-min-free-mib(기본 4096)만큼 디스크 여유를 확인한 뒤 진행됩니다. 삭제 동작은 없으니 관리는 사용자 몫입니다.
코딩 도구 연결 예제
HTTP를 직접 다루지 않을 때의 흐름은 이렇습니다.
sh
strata launch --family qwen --model iq3_xxs --context 128k --yes --no-tui
strata connect claude-code # 설정 출력(주소·키·모델·컨텍스트)
strata connect claude-code --write # 확인 후 앱 설정 파일에 기록(백업 후)
strata connect claude-code --check # 프롬프트·도구 호출로 실연결 점검같은 서버를 Codex CLI(codex), OpenCode(opencode), pi(pi) 등에도 같은 방식으로 붙입니다. 여러 도구를 병렬로 쓰면 launch의 --parallel을 카드에 맞게 올리고, 클라이언트 폭주가 걱정되면 --max-queue/--queue-timeout으로 admission 상단을 잡습니다(초과는 429 admission_full).
여기까지가 Strata의 전체 학습 흐름입니다. 개념이 다시 필요하면 동작 원리 편으로, 운영 세부로 들어가려면 튜닝·운영 편으로 돌아오세요.