---
title: Anthropic Messages | RunAPI
description: Wyślij żądanie przez operację Messages kompatybilną z Anthropic w RunAPI.
url: https://runapi.ai/pl/docs/api/anthropic/messages.md
canonical: https://runapi.ai/pl/docs/api/anthropic/messages
locale: pl
---

> Wersja HTML: https://runapi.ai/pl/docs/api/anthropic/messages
> Indeks witryny dla agentów: https://runapi.ai/llms.txt

# Anthropic Messages

## Omówienie

Użyj operacji Messages zgodnej z Anthropic w RunAPI z kompatybilnym modelem oraz kształtami żądania i odpowiedzi tego protokołu.

### Szybki start

1. Utwórz klucz API i ustaw go jako RUNAPI_API_KEY.
2. Wybierz zgodny model, a następnie wyślij udokumentowane parametry ścieżki i treść JSON.
3. Odczytaj odpowiedź JSON lub zdarzenia wysyłane przez serwer pokazane dla tej operacji i obsłuż błędy protokołu.

## Punkt końcowy

POST /v1/messages

Bazowy URL: https://runapi.ai

Wersja kontraktu: v1

Preferowane uwierzytelnianie: x-api-key: YOUR_API_TOKEN

## Nośniki uwierzytelniania

RunAPI akceptuje każdy z wymienionych poniżej protokołów. Wygenerowane przykłady używają preferowanego nagłówka danego protokołu.

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

## Zgodne modele

Otwórz stronę modelu, aby zapoznać się z aktualnymi cenami, limitami żądań i szczegółami dotyczącymi użytku komercyjnego.

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

## Kontrakt żądania

Wymieniane są tylko pola mające zarówno publiczną dokumentację protokołu, jak i potwierdzenie obsługi przez RunAPI. Dodatkowe pola treści JSON są przekazywane bez zmian.

### Treść JSON

Wymagane: `model`, `max_tokens`, `messages`

```json
{
  "max_tokens": {
    "description": "Maksymalna liczba tokenów do wygenerowania przed zatrzymaniem.",
    "type": "integer"
  },
  "messages": {
    "description": "Tury rozmowy w formacie Anthropic Messages.",
    "items": {
      "additionalProperties": true,
      "properties": {
        "content": {
          "type": [
            "string",
            "array"
          ]
        },
        "role": {
          "type": "string"
        }
      },
      "required": [
        "role",
        "content"
      ],
      "type": "object"
    },
    "type": "array"
  },
  "model": {
    "description": "Identyfikator modelu RunAPI zwrócony przez kompatybilny katalog modeli.",
    "type": "string"
  },
  "stream": {
    "default": false,
    "description": "Zwróć typowane zdarzenia Messages jako zdarzenia wysyłane przez serwer.",
    "type": "boolean"
  },
  "system": {
    "description": "Instrukcje systemowe przekazywane osobno od wiadomości konwersacyjnych.",
    "type": [
      "string",
      "array"
    ]
  },
  "temperature": {
    "description": "Temperatura próbkowania; obsługa przez model może się różnić.",
    "type": "number"
  },
  "tools": {
    "description": "Narzędzia, które model może wywoływać.",
    "type": "array"
  },
  "top_p": {
    "description": "Prawdopodobieństwo próbkowania jądra; obsługa przez model może być różna.",
    "type": "number"
  }
}
```

### Przykład żądania

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

## Odpowiedź synchroniczna

HTTP 200

### Schemat

```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"
}
```

### Przykład

```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
  }
}
```

## Zdarzenie SSE: message_start

Typ mediów: `text/event-stream`

### Schemat

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

### Przykład

```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"
}
```

## Zdarzenie SSE: content_block_delta

Typ mediów: `text/event-stream`

### Schemat

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

### Przykład

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

## Zdarzenie SSE: message_delta

Typ mediów: `text/event-stream`

### Schemat

```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"
}
```

### Przykład

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

## Zdarzenie SSE: message_stop

Typ mediów: `text/event-stream`

### Schemat

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

### Przykład

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

## Błąd protokołu: invalid_request

HTTP 400

### Schemat

```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"
}
```

### Przykład

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

## Użycie

### Schemat

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

### Przykład

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

## Wygenerowane przykłady kodu

Każdy przykład cURL, JavaScript i Python wysyła zwalidowane żądanie z tej specyfikacji bez konieczności używania SDK właściwego dla protokołu.

### 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

#### Instalacja

```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())
```

## Powiązane przewodniki

- [Uwierzytelnianie](https://runapi.ai/pl/docs/guides/authentication.md)
- [Szybki start](https://runapi.ai/pl/docs/guides/llm-api/quickstart.md)

---

## Więcej od RunAPI

- [Strona główna](https://runapi.ai/pl/.md)
- [Katalog modeli](https://runapi.ai/pl/models.md)
- [Cennik](https://runapi.ai/pl/pricing.md)
- [Dostawcy](https://runapi.ai/pl/models)
- [Dokumentacja](https://runapi.ai/pl/docs/guides)
- [SDK](https://runapi.ai/pl/sdk.md)
- [CLI](https://runapi.ai/pl/cli.md)
- [Serwer MCP](https://runapi.ai/pl/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/pl/claude-code-vs-cursor.md)
- [Konfiguracja Cursor API](https://runapi.ai/pl/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/pl/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/pl/contact.md)
- [Kontakt](https://runapi.ai/pl/contact.md)
- [Regulamin](https://runapi.ai/pl/terms.md)
- [Prywatność](https://runapi.ai/pl/privacy.md)
- [Indeks witryny dla agentów](https://runapi.ai/llms.txt)

Kontakt: contact@runapi.ai

## Dane strukturalne

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "pl",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/pl",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/pl/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "pl",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/pl",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/plicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "pl",
    "@type": "TechArticle",
    "headline": "Anthropic Messages",
    "description": "Wyślij żądanie przez operację Messages kompatybilną z Anthropic w RunAPI.",
    "url": "https://runapi.ai/pl/docs/api/anthropic/messages",
    "mainEntityOfPage": "https://runapi.ai/pl/docs/api/anthropic/messages"
  }
]
```
