Messages API
Erstellen Sie Claude-Konversationen über das native Anthropic-Protokoll. OfoxAI ist vollständig kompatibel mit der Anthropic Messages API — Sie können direkt das offizielle SDK verwenden.
Endpunkt
POST https://api.ofox.ai/anthropic/v1/messagesAuthentifizierung
Das Anthropic-Protokoll verwendet den x-api-key Header:
x-api-key: <Ihr OFOXAI_API_KEY>
anthropic-version: 2023-06-01Anfrageparameter
| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
model | string | ✅ | Modellkennung, z.B. anthropic/claude-sonnet-4.5 |
max_tokens | number | ✅ | Maximale Anzahl generierter Tokens |
messages | array | ✅ | Nachrichtenarray |
system | string | — | System-Prompt |
temperature | number | — | Sampling-Temperatur 0-1 |
top_p | number | — | Nucleus-Sampling-Parameter |
top_k | number | — | Top-K-Sampling |
stream | boolean | — | Streaming-Antwort aktivieren |
tools | array | — | Tool-Definitionen |
tool_choice | object | — | Tool-Auswahlstrategie |
Message-Format
interface Message {
role: 'user' | 'assistant'
content: string | ContentBlock[]
}
type ContentBlock =
| { type: 'text'; text: string }
| { type: 'image'; source: { type: 'base64'; media_type: string; data: string } }
| { type: 'tool_use'; id: string; name: string; input: object }
| { type: 'tool_result'; tool_use_id: string; content: string }Anfragebeispiele
cURL
Terminal
curl https://api.ofox.ai/anthropic/v1/messages \
-H "x-api-key: $OFOX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.5",
"max_tokens": 1024,
"system": "Sie sind ein professioneller Programmierassistent.",
"messages": [
{"role": "user", "content": "Schreiben Sie einen Quicksort-Algorithmus in Python"}
]
}'Antwortformat
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hier ist eine Quicksort-Implementierung in Python..."
}
],
"model": "anthropic/claude-sonnet-4.5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 200
}
}Streaming-Antwort
Python
anthropic_stream.py
with client.messages.stream(
model="anthropic/claude-sonnet-4.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Erzählen Sie eine Geschichte"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Unterstützte Modelle
| Modell | Beschreibung |
|---|---|
anthropic/claude-opus-4.6 | Claude Opus 4 — Höchste Leistung |
anthropic/claude-sonnet-4.5 | Claude Sonnet 4 — Ausgewogene Performance |
anthropic/claude-haiku-4.5 | Claude Haiku 4.5 — Schnelle Antworten |
Das Anthropic-Protokoll von OfoxAI unterstützt alle nativen Funktionen, einschließlich Vision, Tool Use, Prompt Caching, Extended Thinking und mehr.
Last updated on