View source: R/provider_anthropic.R
| stream_anthropic | R Documentation |
Makes a streaming POST request to Anthropic and processes their SSE format.
Anthropic uses event types like content_block_delta instead of OpenAI's format.
Also handles OpenAI-compatible format for proxy servers.
stream_anthropic(
url,
headers,
body,
callback,
max_retries = 5,
initial_delay_ms = 2000,
backoff_factor = 2,
timeout_seconds = NULL,
total_timeout_seconds = NULL,
first_byte_timeout_seconds = NULL,
connect_timeout_seconds = NULL,
idle_timeout_seconds = NULL
)
url |
The API endpoint URL. |
headers |
A named list of HTTP headers. |
body |
The request body (will be converted to JSON). |
callback |
A function called for each text delta. |
max_retries |
Maximum number of connection/first-event retries before any stream chunk has been delivered. |
initial_delay_ms |
Initial delay in milliseconds. |
backoff_factor |
Multiplier for delay on each retry. |
timeout_seconds |
Legacy alias for |
total_timeout_seconds |
Optional total stream timeout in seconds. |
first_byte_timeout_seconds |
Optional time-to-first-byte timeout in seconds. |
connect_timeout_seconds |
Optional connection-establishment timeout in seconds. |
idle_timeout_seconds |
Optional stall timeout in seconds. |
A GenerateResult object.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.