curl https://api.anthropic.com/v1/complete \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--data '
{
"model": "claude-2",
"prompt": "\n\nHuman: Hello, world!\n\nAssistant:",
"max_tokens_to_sample": 256,
"stream": true
}
'
event: completion
data: {"type": "completion", "completion": " Hello", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": "!", "stop_reason": null, "model": "claude-2.0"}
event: ping
data: {"type": "ping"}
event: completion
data: {"type": "completion", "completion": " My", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": " name", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": " is", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": " Claude", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": ".", "stop_reason": null, "model": "claude-2.0"}
event: completion
data: {"type": "completion", "completion": "", "stop_reason": "stop_sequence", "model": "claude-2.0"}
각 이벤트는 명명된 이벤트 유형과 관련 JSON 데이터를 포함합니다.
event: completion
data: {"completion": " Hello", "stop_reason": null, "model": "claude-2.0"}
event: error
data: {"error": {"type": "overloaded_error", "message": "Overloaded"}}