---
title: Anthropic Messages | RunAPI
description: Eine Anfrage über RunAPIs Anthropic-kompatible Messages-Operation senden.
url: https://runapi.ai/de/docs/api/anthropic/messages.md
canonical: https://runapi.ai/de/docs/api/anthropic/messages
locale: de
---

> HTML-Version: https://runapi.ai/de/docs/api/anthropic/messages
> Website-Index für KI-Agenten: https://runapi.ai/llms.txt

# Anthropic Messages

## Übersicht

RunAPIs Anthropic-kompatible Messages-Operation mit einem kompatiblen Modell sowie den Anfrage- und Antwortformaten des Protokolls verwenden.

### Schnellstart

1. Erstellen Sie einen API-Schlüssel und setzen Sie ihn als RUNAPI_API_KEY.
2. Wählen Sie ein kompatibles Modell, senden Sie dann die dokumentierten Pfadparameter und den JSON-Body.
3. Lesen Sie die für diesen Vorgang angezeigte JSON-Antwort oder die server-sent events und behandeln Sie Protokollfehler.

## Endpunkt

POST /v1/messages

Basis-URL: https://runapi.ai

Vertragsversion: v1

Bevorzugte Authentifizierung: x-api-key: YOUR_API_TOKEN

## Authentifizierungsträger

RunAPI akzeptiert jeden der unten aufgeführten Träger. Generierte Beispiele verwenden den bevorzugten Header des Protokolls.

- `Authorization: Bearer YOUR_API_TOKEN`
- `x-api-key: YOUR_API_TOKEN` (Bevorzugt)
- `x-goog-api-key: YOUR_API_TOKEN`
- `?key=YOUR_API_TOKEN`

## Kompatible Modelle

Öffnen Sie eine Modellseite für aktuelle Preise, Ratenlimits und Details zur kommerziellen Nutzung.

- [claude-fable-5-1](https://runapi.ai/de/models/claude)
- [claude-fable-5](https://runapi.ai/de/models/claude)
- [claude-sonnet-5](https://runapi.ai/de/models/claude)
- [claude-opus-5](https://runapi.ai/de/models/claude)
- [claude-opus-4-8](https://runapi.ai/de/models/claude)
- [claude-opus-4-7](https://runapi.ai/de/models/claude)
- [claude-opus-4-6](https://runapi.ai/de/models/claude)
- [claude-sonnet-4-6](https://runapi.ai/de/models/claude)
- [claude-opus-4-5-20251101](https://runapi.ai/de/models/claude)
- [claude-sonnet-4-5-20250929](https://runapi.ai/de/models/claude)
- [claude-haiku-4-5-20251001](https://runapi.ai/de/models/claude)
- [claude-opus-4-1-20250805](https://runapi.ai/de/models/claude)
- [gpt-5.5](https://runapi.ai/de/models/gpt)
- [gpt-5.5-pro](https://runapi.ai/de/models/gpt)
- [gpt-5.4](https://runapi.ai/de/models/gpt)
- [gpt-5.4-mini](https://runapi.ai/de/models/gpt)
- [gpt-5.4-nano](https://runapi.ai/de/models/gpt)
- [gpt-5.4-pro](https://runapi.ai/de/models/gpt)
- [gpt-5.3-codex](https://runapi.ai/de/models/gpt)
- [gpt-5.3-codex-spark](https://runapi.ai/de/models/gpt)
- [gpt-5.2](https://runapi.ai/de/models/gpt)
- [gpt-5.6-luna](https://runapi.ai/de/models/gpt)
- [gpt-5.6-sol](https://runapi.ai/de/models/gpt)
- [gpt-5.6-terra](https://runapi.ai/de/models/gpt)
- [gpt-6-astra](https://runapi.ai/de/models/gpt)
- [gemini-3.6-flash](https://runapi.ai/de/models/gemini)
- [gemini-3.5-flash](https://runapi.ai/de/models/gemini)
- [gemini-3.1-pro-preview](https://runapi.ai/de/models/gemini)
- [gemini-3-flash-preview](https://runapi.ai/de/models/gemini)
- [gemini-2.5-pro](https://runapi.ai/de/models/gemini)
- [gemini-2.5-flash](https://runapi.ai/de/models/gemini)
- [deepseek-v4-flash-vision-exp](https://runapi.ai/de/models/deepseek)
- [deepseek-v4-pro](https://runapi.ai/de/models/deepseek)
- [deepseek-v4-flash](https://runapi.ai/de/models/deepseek)
- [glm-5.2](https://runapi.ai/de/models/glm)
- [glm-5.1](https://runapi.ai/de/models/glm)
- [glm-5-turbo](https://runapi.ai/de/models/glm)
- [glm-5](https://runapi.ai/de/models/glm)
- [glm-4.7](https://runapi.ai/de/models/glm)
- [glm-4.6](https://runapi.ai/de/models/glm)
- [glm-4.5](https://runapi.ai/de/models/glm)
- [glm-4.5-air](https://runapi.ai/de/models/glm)
- [kimi-k3](https://runapi.ai/de/models/kimi)
- [kimi-k2.7-code](https://runapi.ai/de/models/kimi)
- [kimi-k2.6](https://runapi.ai/de/models/kimi)
- [kimi-k2.5](https://runapi.ai/de/models/kimi)
- [MiniMax-M3](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.7](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.7-highspeed](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.5](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.5-highspeed](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.1](https://runapi.ai/de/models/minimax)
- [MiniMax-M2](https://runapi.ai/de/models/minimax)
- [mimo-v2.5-pro](https://runapi.ai/de/models/mimo)
- [mimo-v2.5](https://runapi.ai/de/models/mimo)
- [grok-4.20-0309-non-reasoning](https://runapi.ai/de/models/grok)
- [grok-4.5](https://runapi.ai/de/models/grok)
- [grok-4.3](https://runapi.ai/de/models/grok)

## Anfrage-Vertrag

Es werden nur Felder aufgeführt, für die sowohl öffentliche Protokoll- als auch RunAPI-Unterstützung belegt ist. Weitere JSON-Body-Felder werden durchgereicht.

### JSON-Body

Erforderlich: `model`, `max_tokens`, `messages`

```json
{
  "max_tokens": {
    "description": "Maximale Anzahl zu generierender Tokens vor dem Stopp.",
    "type": "integer"
  },
  "messages": {
    "description": "Gesprächsrunden im Anthropic Messages-Format.",
    "items": {
      "additionalProperties": true,
      "properties": {
        "content": {
          "type": [
            "string",
            "array"
          ]
        },
        "role": {
          "type": "string"
        }
      },
      "required": [
        "role",
        "content"
      ],
      "type": "object"
    },
    "type": "array"
  },
  "model": {
    "description": "RunAPI-Modellbezeichner, der vom kompatiblen Modellkatalog zurückgegeben wird.",
    "type": "string"
  },
  "stream": {
    "default": false,
    "description": "Typisierte Messages-Ereignisse als Server-Sent Events zurückgeben.",
    "type": "boolean"
  },
  "system": {
    "description": "Systemanweisungen, die separat von Konversationsnachrichten übergeben werden.",
    "type": [
      "string",
      "array"
    ]
  },
  "temperature": {
    "description": "Sampling-Temperatur; die Modellunterstützung kann variieren.",
    "type": "number"
  },
  "tools": {
    "description": "Tools, die das Modell aufrufen darf.",
    "type": "array"
  },
  "top_p": {
    "description": "Nucleus-Sampling-Wahrscheinlichkeit; die Modellunterstützung kann variieren.",
    "type": "number"
  }
}
```

### Anfragebeispiel

```json
{
  "max_tokens": 64,
  "messages": [
    {
      "content": "Summarize one practical improvement for an API deployment.",
      "role": "user"
    }
  ],
  "model": "claude-sonnet-4-6"
}
```

## Synchrone Antwort

HTTP 200

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "content": {
      "type": "array"
    },
    "id": {
      "type": "string"
    },
    "model": {
      "type": "string"
    },
    "role": {
      "const": "assistant",
      "type": "string"
    },
    "stop_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "type": {
      "const": "message",
      "type": "string"
    },
    "usage": {
      "additionalProperties": true,
      "properties": {
        "input_tokens": {
          "type": "integer"
        },
        "output_tokens": {
          "type": "integer"
        }
      },
      "required": [
        "input_tokens",
        "output_tokens"
      ],
      "type": "object"
    }
  },
  "required": [
    "id",
    "type",
    "role",
    "content",
    "model",
    "stop_reason",
    "usage"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "content": [
    {
      "text": "Hello! How can I help today?",
      "type": "text"
    }
  ],
  "id": "msg_example",
  "model": "claude-sonnet-4-6",
  "role": "assistant",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "type": "message",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 8
  }
}
```

## SSE event: message_start

Medientyp: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "message": {
      "type": "object"
    },
    "type": {
      "const": "message_start",
      "type": "string"
    }
  },
  "required": [
    "type",
    "message"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "message": {
    "content": [],
    "id": "msg_example",
    "model": "claude-sonnet-4-6",
    "role": "assistant",
    "stop_reason": null,
    "stop_sequence": null,
    "type": "message",
    "usage": {
      "input_tokens": 12,
      "output_tokens": 1
    }
  },
  "type": "message_start"
}
```

## SSE event: content_block_delta

Medientyp: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "delta": {
      "type": "object"
    },
    "index": {
      "type": "integer"
    },
    "type": {
      "const": "content_block_delta",
      "type": "string"
    }
  },
  "required": [
    "type",
    "index",
    "delta"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "delta": {
    "text": "Hello",
    "type": "text_delta"
  },
  "index": 0,
  "type": "content_block_delta"
}
```

## SSE event: message_delta

Medientyp: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "delta": {
      "type": "object"
    },
    "type": {
      "const": "message_delta",
      "type": "string"
    },
    "usage": {
      "additionalProperties": true,
      "properties": {
        "output_tokens": {
          "type": "integer"
        }
      },
      "required": [
        "output_tokens"
      ],
      "type": "object"
    }
  },
  "required": [
    "type",
    "delta",
    "usage"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "delta": {
    "stop_reason": "end_turn",
    "stop_sequence": null
  },
  "type": "message_delta",
  "usage": {
    "output_tokens": 8
  }
}
```

## SSE event: message_stop

Medientyp: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "type": {
      "const": "message_stop",
      "type": "string"
    }
  },
  "required": [
    "type"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "type": "message_stop"
}
```

## Protokollfehler: invalid_request

HTTP 400

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "message"
      ],
      "type": "object"
    },
    "request_id": {
      "type": "string"
    },
    "type": {
      "const": "error",
      "type": "string"
    }
  },
  "required": [
    "type",
    "error"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "error": {
    "message": "max_tokens is required",
    "type": "invalid_request_error"
  },
  "request_id": "req_example",
  "type": "error"
}
```

## Verwendung

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "input_tokens": {
      "type": "integer"
    },
    "output_tokens": {
      "type": "integer"
    }
  },
  "required": [
    "input_tokens",
    "output_tokens"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "input_tokens": 12,
  "output_tokens": 8
}
```

## Generierte Code-Beispiele

Jedes cURL-, JavaScript- und Python-Beispiel sendet die validierte Anfrage aus diesem Vertrag, ohne ein protokollspezifisches SDK zu benötigen.

### curl

```curl
curl -X POST https://runapi.ai/v1/messages \
  -H x-api-key:\ YOUR_API_TOKEN \
  -H Content-Type:\ application/json \
  -d \{\"model\":\"claude-sonnet-4-6\",\"max_tokens\":64,\"messages\":\[\{\"role\":\"user\",\"content\":\"Summarize\ one\ practical\ improvement\ for\ an\ API\ deployment.\"\}\]\}
```

### javascript

```javascript
const response = await fetch("https://runapi.ai/v1/messages", {
  method: "POST",
  headers: {
  "x-api-key": "YOUR_API_TOKEN",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "claude-sonnet-4-6",
  "max_tokens": 64,
  "messages": [
    {
      "role": "user",
      "content": "Summarize one practical improvement for an API deployment."
    }
  ]
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);
```

### python

#### Installieren

```bash
pip install requests
```

```python
import requests

response = requests.post(
    "https://runapi.ai/v1/messages",
    headers={"x-api-key": "YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"model": "claude-sonnet-4-6", "max_tokens": 64, "messages": [{"role": "user", "content": "Summarize one practical improvement for an API deployment."}]}
)
response.raise_for_status()
print(response.json())
```

## Verwandte Anleitungen

- [Authentifizierung](https://runapi.ai/de/docs/guides/authentication.md)
- [Schnellstart](https://runapi.ai/de/docs/guides/llm-api/quickstart.md)

---

## Mehr von RunAPI

- [Startseite](https://runapi.ai/de/.md)
- [Modellkatalog](https://runapi.ai/de/models.md)
- [Preise](https://runapi.ai/de/pricing.md)
- [Anbieter](https://runapi.ai/de/models)
- [Dokumentation](https://runapi.ai/de/docs/guides)
- [SDKs](https://runapi.ai/de/sdk.md)
- [CLI](https://runapi.ai/de/cli.md)
- [MCP Server](https://runapi.ai/de/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/de/claude-code-vs-cursor.md)
- [Cursor API-Einrichtung](https://runapi.ai/de/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/de/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/de/contact.md)
- [Kontakt](https://runapi.ai/de/contact.md)
- [Bedingungen](https://runapi.ai/de/terms.md)
- [Datenschutz](https://runapi.ai/de/privacy.md)
- [Website-Index für KI-Agenten](https://runapi.ai/llms.txt)

Kontakt: contact@runapi.ai

## Strukturierte Daten

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/de",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/de/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/de",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/deicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "TechArticle",
    "headline": "Anthropic Messages",
    "description": "Eine Anfrage über RunAPIs Anthropic-kompatible Messages-Operation senden.",
    "url": "https://runapi.ai/de/docs/api/anthropic/messages",
    "mainEntityOfPage": "https://runapi.ai/de/docs/api/anthropic/messages"
  }
]
```
