แชทของ Claude

post/v1/messages

รูปแบบ Anthropic Claude Messages API ต้องระบุ header anthropic-version ในคำขอ

การยืนยันตัวตน

ส่งคีย์ API ของ OLETOKEN เป็น Bearer token สร้างคีย์ได้ที่หน้า API Keys ในคอนโซล

Authorization: Bearer $OLETOKEN_API_KEY

พารามิเตอร์

ฟิลด์ประเภทจำเป็นคำอธิบาย
anthropic-versionheaderstringเวอร์ชันของ Anthropic API
x-api-keyheaderstring—คีย์ Anthropic API (ไม่บังคับ; ใช้ Bearer token ก็ได้)

เนื้อหาคำขอ

Content-Type:application/json

ฟิลด์ประเภทจำเป็นคำอธิบาย
modelstring—
messagesClaudeMessage[]—
rolestringuserassistant—
contentstring | object[]—
typestringtextimagetool_usetool_result——
textstring——
sourceobject——
typestringbase64url——
media_typestring——
datastring——
urlstring——
idstring——
namestring——
inputobject——
tool_use_idstring——
contentstring——
systemstring | object[]——
cache_controlobject——
inference_geostring——
max_tokensinteger≥ 1—
temperaturenumber0–1——
top_pnumber——
top_kinteger——
streamboolean——
stop_sequencesstring[]——
toolsobject[]——
namestring——
descriptionstring——
input_schemaobject——
tool_choiceobject——
typestringautoanytoolnone——
namestring——
thinkingobject——
typestringenableddisabled——
budget_tokensinteger——
context_managementobject——
output_configobject——
output_formatobject——
containerstring | object——
mcp_serversobject[]——
metadataobject——
user_idstring——
speedstringstandardfast——
service_tierstringautostandard_only——

การตอบกลับ

200สร้างการตอบกลับแล้ว

ฟิลด์ประเภทจำเป็นคำอธิบาย
idstring——
typestring——
rolestring——
contentobject[]——
typestring——
textstring——
modelstring——
stop_reasonstringend_turnmax_tokensstop_sequencetool_use——
usageobject——
input_tokensinteger——
output_tokensinteger——
cache_creation_input_tokensinteger——
cache_read_input_tokensinteger——

ตัวอย่างคำขอ

curl -X POST 'https://api.oletoken.ai/v1/messages' \
  -H "Authorization: Bearer $OLETOKEN_API_KEY" \
  -H 'anthropic-version:' \
  -H 'x-api-key:' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "claude-3-opus-20240229",
    "messages": [],
    "max_tokens": 0
  }'