{
  "name": "forge-provider-anthropic",
  "language": "rust",
  "version": "0.2.0",
  "description": "Anthropic provider for the Forge SDK \u2014 implements the LanguageModel trait for the Anthropic Messages API",
  "manifest": "forge-rs/crates/forge-provider-anthropic/Cargo.toml",
  "manifestSha256": "d729a56208ec7259f3264dca98385e0fae958af288a668c4222e746785aa3d3d",
  "status": "source-reference",
  "registryPublicationVerified": false,
  "route": "/libraries/rust/forge-provider-anthropic",
  "features": {},
  "files": [
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/client.rs",
      "sha256": "5661d6b581f075b5df14c016559ac77ea6799a208800e584341ff6cfc66f4c39",
      "artifactSha256": "06f7372450051527142eaa146d40b2d35159dbe1387faddc43e0686681427aef",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/client.rs.txt",
      "declarations": [
        {
          "name": "::AnthropicHttpClient",
          "line": 40,
          "signature": "pub struct AnthropicHttpClient {\n\n}",
          "documentation": "HTTP client wrapper for the Anthropic Messages API.\n\nManages connection pooling, authentication headers, and retry logic\nfor transient failures (429, 500, 503).\n\n# Examples\n\n```no_run\nuse forge_provider_anthropic::config::AnthropicConfig;\nuse forge_provider_anthropic::client::AnthropicHttpClient;\n\n# async fn example() -> Result<(), Box<dyn std::error::Error>> {\nlet config = AnthropicConfig::new(\"sk-ant-api03-...\");\nlet client = AnthropicHttpClient::new(&config)?;\n# Ok(())\n# }\n```"
        },
        {
          "name": "::AnthropicHttpClient::new",
          "line": 72,
          "signature": "pub fn new(config: &AnthropicConfig) -> Result<Self, AnthropicError>;",
          "documentation": "Creates a new HTTP client from the given configuration.\n\n# Arguments\n\n* `config` - The Anthropic configuration containing API key and endpoints.\n\n# Returns\n\nThe configured HTTP client.\n\n# Errors\n\nReturns `AnthropicError::InvalidConfig` if the API key is empty."
        },
        {
          "name": "::AnthropicHttpClient::send_messages",
          "line": 109,
          "signature": "pub async fn send_messages(\n        &self,\n        request: &MessagesRequest,\n    ) -> Result<MessagesResponse, AnthropicError>;",
          "documentation": "Sends a non-streaming Messages API request and returns the parsed response.\n\nHandles retry logic for transient HTTP errors (429, 500, 503).\n\n# Arguments\n\n* `request` - The serialized Messages API request.\n\n# Returns\n\nThe deserialized `MessagesResponse`.\n\n# Errors\n\nReturns `AnthropicError` for HTTP failures, API errors, and\ndeserialization failures."
        },
        {
          "name": "::AnthropicHttpClient::send_streaming",
          "line": 187,
          "signature": "pub async fn send_streaming(\n        &self,\n        request: &MessagesRequest,\n    ) -> Result<Vec<u8>, AnthropicError>;",
          "documentation": "Sends a streaming Messages API request and returns the raw response body.\n\nThe caller is responsible for parsing the SSE stream. Retry logic is\nnot applied to streaming requests because partial responses cannot\nbe resumed.\n\n# Arguments\n\n* `request` - The serialized Messages API request (must have `stream: true`).\n\n# Returns\n\nA tuple of the HTTP status and the raw response body bytes.\n\n# Errors\n\nReturns `AnthropicError` for HTTP failures and non-2xx responses."
        },
        {
          "name": "::AnthropicHttpClient::send_streaming_body",
          "line": 222,
          "signature": "pub async fn send_streaming_body(\n        &self,\n        request: &MessagesRequest,\n    ) -> Result<Incoming, AnthropicError>;",
          "documentation": "Sends a streaming request and returns the response body **without\ncollecting it**. The caller drives the body frame-by-frame to deliver\nSSE events to consumers as the upstream wire produces them.\n\nUsed by `LanguageModel::stream_chunks` (RFC 0001 / F-6 / F-7) \u2014 see\n[`crate::model`] for the full pipeline that wires this body into\n[`crate::sse::SseDecoder`] and [`crate::sse::ChunkEmitter`].\n\n# Errors\n\n- [`AnthropicError::HttpTransport`] if the request fails to send\n  or the headers can't be read.\n- [`AnthropicError::ApiError`] (with the body collected eagerly) if\n  the response status is non-2xx \u2014 error bodies are small enough\n  that buffering them is the right tradeoff vs. trying to stream a\n  failure."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/config.rs",
      "sha256": "1ae87a2450273990205490f0ee359102fbc5d11539e022e67f66224a3b19088e",
      "artifactSha256": "c63f440756fc3e7388c7791dacc1044856d6ff6eda0971d15682e66a95899a76",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/config.rs.txt",
      "declarations": [
        {
          "name": "::DEFAULT_MAX_TOKENS",
          "line": 24,
          "signature": "pub const DEFAULT_MAX_TOKENS: u32;",
          "documentation": "Default max_tokens value when the caller does not specify one.\n\nAnthropic requires `max_tokens` on every request. When\n`GenerateOptions::max_tokens` is `None`, this value is used."
        },
        {
          "name": "::AnthropicConfig",
          "line": 44,
          "signature": "#[derive(Clone)]\npub struct AnthropicConfig {\n\n}",
          "documentation": "Configuration for the Anthropic provider.\n\nContains the API key, base URL, API version header, timeout, and retry\nsettings. The [`Debug`] implementation redacts the API key.\n\n# Examples\n\n```\nuse forge_provider_anthropic::AnthropicConfig;\n\nlet config = AnthropicConfig::new(\"sk-ant-api03-...\")\n    .with_model(\"claude-sonnet-4-5-20250929\")\n    .with_timeout_seconds(60);\n\nassert_eq!(config.model(), \"claude-sonnet-4-5-20250929\");\nassert_eq!(config.base_url(), \"https://api.anthropic.com/v1\");\n```"
        },
        {
          "name": "::AnthropicConfig::new",
          "line": 75,
          "signature": "pub fn new(api_key: impl Into<String>) -> Self;",
          "documentation": "Creates a new configuration with the given API key and default settings.\n\n# Arguments\n\n* `api_key` - The Anthropic API key (starts with `sk-ant-`).\n\n# Examples\n\n```\nuse forge_provider_anthropic::AnthropicConfig;\n\nlet config = AnthropicConfig::new(\"sk-ant-api03-...\");\nassert_eq!(config.base_url(), \"https://api.anthropic.com/v1\");\nassert_eq!(config.api_version(), \"2023-06-01\");\n```"
        },
        {
          "name": "::AnthropicConfig::no_credentials",
          "line": 109,
          "signature": "pub fn no_credentials() -> Self;",
          "documentation": "Builds a config with no API key, intended for mock-mode boot paths.\n\nUse this when constructing the config at boot before knowing whether\nreal credentials are configured (e.g., `ANTHROPIC_API_KEY` may be unset\nin dev or CI). The returned config is structurally identical to one\nbuilt with [`new`](Self::new), but the API key is empty -- the actual\nrequest layer is responsible for surfacing a clear error if a real\nrequest is attempted without credentials, instead of failing at\nconstruction.\n\nThis lets callers write a single straight-line code path and decide\nat request time whether to short-circuit to mock-mode, rather than\nthreading `Option<AnthropicConfig>` through their agent type.\n\n```\nuse forge_provider_anthropic::AnthropicConfig;\n\nlet config = match std::env::var(\"ANTHROPIC_API_KEY\") {\n    Ok(key) if !key.is_empty() => AnthropicConfig::new(key),\n    _ => AnthropicConfig::no_credentials(),\n};\nassert!(!config.has_credentials() || !config.api_key().is_empty());\n```"
        },
        {
          "name": "::AnthropicConfig::has_credentials",
          "line": 124,
          "signature": "pub fn has_credentials(&self) -> bool;",
          "documentation": "Returns whether this config carries a non-empty API key.\n\nUse this to short-circuit to mock-mode without inspecting the redacted\nkey directly:\n\n```\nuse forge_provider_anthropic::AnthropicConfig;\n\nassert!(!AnthropicConfig::no_credentials().has_credentials());\nassert!(AnthropicConfig::new(\"sk-ant-real\").has_credentials());\n```"
        },
        {
          "name": "::AnthropicConfig::with_model",
          "line": 133,
          "signature": "pub fn with_model(mut self, model: impl Into<String>) -> Self;",
          "documentation": "Sets the model identifier.\n\n# Arguments\n\n* `model` - The model to use (e.g., \"claude-sonnet-4-5-20250929\", \"claude-opus-4-5-20250416\")."
        },
        {
          "name": "::AnthropicConfig::with_base_url",
          "line": 143,
          "signature": "pub fn with_base_url(mut self, base_url: impl Into<String>) -> Self;",
          "documentation": "Sets the base URL for the API.\n\n# Arguments\n\n* `base_url` - The base URL (e.g., `https://api.anthropic.com/v1`)."
        },
        {
          "name": "::AnthropicConfig::with_api_version",
          "line": 153,
          "signature": "pub fn with_api_version(mut self, version: impl Into<String>) -> Self;",
          "documentation": "Sets the API version header.\n\n# Arguments\n\n* `version` - The `anthropic-version` header value."
        },
        {
          "name": "::AnthropicConfig::with_timeout_seconds",
          "line": 163,
          "signature": "pub fn with_timeout_seconds(mut self, seconds: u64) -> Self;",
          "documentation": "Sets the request timeout in seconds.\n\n# Arguments\n\n* `seconds` - Timeout in seconds."
        },
        {
          "name": "::AnthropicConfig::with_max_retries",
          "line": 173,
          "signature": "pub fn with_max_retries(mut self, retries: u32) -> Self;",
          "documentation": "Sets the maximum number of retries for transient HTTP errors.\n\n# Arguments\n\n* `retries` - The maximum retry count."
        },
        {
          "name": "::AnthropicConfig::api_key",
          "line": 184,
          "signature": "pub fn api_key(&self) -> &str;",
          "documentation": "Returns the API key.\n\n# Security\n\nDo not log or display the return value. The [`Debug`] implementation\nredacts this field."
        },
        {
          "name": "::AnthropicConfig::model",
          "line": 189,
          "signature": "pub fn model(&self) -> &str;",
          "documentation": "Returns the model identifier."
        },
        {
          "name": "::AnthropicConfig::base_url",
          "line": 194,
          "signature": "pub fn base_url(&self) -> &str;",
          "documentation": "Returns the base URL."
        },
        {
          "name": "::AnthropicConfig::api_version",
          "line": 199,
          "signature": "pub fn api_version(&self) -> &str;",
          "documentation": "Returns the API version header value."
        },
        {
          "name": "::AnthropicConfig::timeout_seconds",
          "line": 204,
          "signature": "pub fn timeout_seconds(&self) -> u64;",
          "documentation": "Returns the request timeout in seconds."
        },
        {
          "name": "::AnthropicConfig::max_retries",
          "line": 209,
          "signature": "pub fn max_retries(&self) -> u32;",
          "documentation": "Returns the maximum retry count."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/error.rs",
      "sha256": "4384a7d539bf316a65bc264cc7d9eb5cf44bb773faed60a6b236c74496f934b2",
      "artifactSha256": "e94c87bcd70bc02118afac4b9c16162e03af83efe52fa4e6d7ccb7df08ceffe8",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/error.rs.txt",
      "declarations": [
        {
          "name": "::AnthropicError",
          "line": 23,
          "signature": "#[derive(Debug, Error)]\npub enum AnthropicError {\n    /// The API returned an HTTP error status code.\n    ///\n    /// Anthropic returns structured error bodies; the `error_type` and `message`\n    /// fields come from the API response.\n    #[error(\n        \"Anthropic API returned HTTP {status_code}: type='{error_type}', message='{message}' \\\n         (model='{model}', request_id='{request_id}')\"\n    )]\n    ApiError {\n        /// The HTTP status code (e.g., 400, 401, 429, 500).\n        status_code: u16,\n        /// The Anthropic error type (e.g., \"invalid_request_error\", \"authentication_error\").\n        error_type: String,\n        /// Human-readable error message from the API.\n        message: String,\n        /// The model that was being called.\n        model: String,\n        /// The request ID from the `request-id` response header, or \"unknown\".\n        request_id: String,\n    },\n\n    /// An HTTP transport error occurred (DNS failure, connection reset, TLS error).\n    #[error(\"HTTP transport error calling Anthropic API at '{url}': {reason}\")]\n    HttpTransport {\n        /// The URL that was being called.\n        url: String,\n        /// Description of the transport failure.\n        reason: String,\n    },\n\n    /// The API response body could not be deserialized.\n    #[error(\n        \"failed to deserialize Anthropic API response for model '{model}': {reason} \\\n         (response snippet: '{snippet}')\"\n    )]\n    DeserializationFailed {\n        /// The model that produced the response.\n        model: String,\n        /// What went wrong during deserialization.\n        reason: String,\n        /// First 200 bytes of the response body for debugging.\n        snippet: String,\n    },\n\n    /// Request serialization failed.\n    #[error(\"failed to serialize request for Anthropic model '{model}': {reason}\")]\n    SerializationFailed {\n        /// The model the request was for.\n        model: String,\n        /// What went wrong during serialization.\n        reason: String,\n    },\n\n    /// An SSE stream event could not be parsed.\n    #[error(\"SSE parse error on event '{event_type}': {reason} (data snippet: '{snippet}')\")]\n    SseParseFailed {\n        /// The SSE event type (e.g., \"content_block_delta\").\n        event_type: String,\n        /// What went wrong.\n        reason: String,\n        /// First 200 bytes of the data field for debugging.\n        snippet: String,\n    },\n\n    /// The request timed out.\n    #[error(\n        \"Anthropic API request timed out after {timeout_seconds}s for model '{model}' \\\n         \u2014 consider increasing timeout or reducing max_tokens\"\n    )]\n    Timeout {\n        /// The model being called.\n        model: String,\n        /// The timeout that was exceeded, in seconds.\n        timeout_seconds: u64,\n    },\n\n    /// All retry attempts were exhausted.\n    #[error(\n        \"Anthropic API request failed after {attempts} attempts for model '{model}': {last_error}\"\n    )]\n    RetriesExhausted {\n        /// The model being called.\n        model: String,\n        /// How many attempts were made.\n        attempts: u32,\n        /// The last error message.\n        last_error: String,\n    },\n\n    /// The configuration is invalid.\n    #[error(\"invalid Anthropic configuration: {reason}\")]\n    InvalidConfig {\n        /// What is wrong with the configuration.\n        reason: String,\n    },\n}",
          "documentation": "Errors specific to the Anthropic provider.\n\nEach variant includes enough context to diagnose the issue: what was\nattempted, what failed, and what to check.\n\n# Conversion\n\n`AnthropicError` converts to `ForgeError` via the [`From`] implementation,\nso provider code can use `?` with `ForgeResult`."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/lib.rs",
      "sha256": "bd38ebeca339f0841657da970e87030ba339de21633d25fa0b0309fef6893ab5",
      "artifactSha256": "a3db53d2af3c12a70497acaa38563ba10df530ed4e40026b2ad060781122e8c0",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/lib.rs.txt",
      "declarations": [
        {
          "name": "client",
          "line": 49,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod client;",
          "documentation": "# forge-provider-anthropic\n\nAnthropic provider for the Forge SDK. Implements the\n[`LanguageModel`](forge_core::model::LanguageModel) trait from `forge-core`\nfor the Anthropic Messages API.\n\nThis crate translates between Forge's unified message/tool model and the\nAnthropic-specific wire format, handling key differences:\n\n- **System prompt**: Anthropic uses a top-level `system` field, not a system message in the array.\n- **Authentication**: `x-api-key` header (not Bearer token), plus `anthropic-version` header.\n- **Content blocks**: Messages contain typed content blocks (text, tool_use, tool_result, image).\n- **Tool schema**: Anthropic uses `input_schema` (not `parameters`).\n- **SSE events**: Anthropic uses a distinct set of SSE event types for streaming.\n- **max_tokens required**: Anthropic requires `max_tokens` on every request; defaults to 4096.\n\n# ANVIL Spec Reference\n\nThis crate implements ANVIL Spec section 6.1 (Cognitive Interface) and section 6.2\n(Provider Abstraction) for the Anthropic provider namespace.\n\n# Examples\n\n```no_run\nuse forge_provider_anthropic::{AnthropicLanguageModel, AnthropicConfig};\nuse forge_core::model::LanguageModel;\nuse forge_core::message::{ModelMessage, Role};\nuse forge_core::config::GenerateOptions;\n\n# async fn example() -> Result<(), Box<dyn std::error::Error>> {\nlet config = AnthropicConfig::new(\"sk-ant-api-key-here\")\n    .with_model(\"claude-sonnet-4-5-20250929\");\nlet model = AnthropicLanguageModel::new(config)?;\n\nlet messages = vec![\n    ModelMessage::text(Role::System, \"You are a helpful assistant.\"),\n    ModelMessage::text(Role::User, \"What is the capital of France?\"),\n];\n\nlet result = model.generate(&messages, &[], &GenerateOptions::default()).await?;\nprintln!(\"{}\", result.text());\n# Ok(())\n# }\n```"
        },
        {
          "name": "config",
          "line": 51,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod config;",
          "documentation": ""
        },
        {
          "name": "error",
          "line": 52,
          "signature": "pub mod error;",
          "documentation": ""
        },
        {
          "name": "model",
          "line": 54,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod model;",
          "documentation": ""
        },
        {
          "name": "sse",
          "line": 56,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod sse;",
          "documentation": ""
        },
        {
          "name": "types",
          "line": 57,
          "signature": "pub mod types;",
          "documentation": ""
        },
        {
          "name": "pub use config::AnthropicConfig;",
          "line": 60,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub use config::AnthropicConfig;",
          "documentation": ""
        },
        {
          "name": "pub use error::AnthropicError;",
          "line": 61,
          "signature": "pub use error::AnthropicError;",
          "documentation": ""
        },
        {
          "name": "pub use model::AnthropicLanguageModel;",
          "line": 63,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub use model::AnthropicLanguageModel;",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/model.rs",
      "sha256": "a55b49df20c2eeda01fde3bc23746da87c80c54bf0fac76ee7b8bf6975584663",
      "artifactSha256": "34eee7a39e22fa4adea07018069522fe7bb88dfb01b495300c989c5bfd5408bc",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/model.rs.txt",
      "declarations": [
        {
          "name": "::AnthropicLanguageModel",
          "line": 79,
          "signature": "pub struct AnthropicLanguageModel {\n\n}",
          "documentation": "Anthropic language model implementing the Forge `LanguageModel` trait.\n\nProvides access to Claude models via the Anthropic Messages API.\nHandles system prompt extraction, content block translation, tool schema\nmapping, and SSE stream parsing.\n\n# ANVIL Spec Reference\n\nImplements ANVIL Spec section 6.1 (Cognitive Interface) and section 6.2 (Provider\nAbstraction) for the \"anthropic\" provider namespace.\n\n# Examples\n\n```no_run\nuse forge_provider_anthropic::{AnthropicLanguageModel, AnthropicConfig};\nuse forge_core::model::LanguageModel;\nuse forge_core::message::{ModelMessage, Role};\nuse forge_core::config::GenerateOptions;\n\n# async fn example() -> Result<(), Box<dyn std::error::Error>> {\nlet config = AnthropicConfig::new(\"sk-ant-api03-...\")\n    .with_model(\"claude-sonnet-4-5-20250929\");\nlet model = AnthropicLanguageModel::new(config)?;\n\nassert_eq!(model.provider(), \"anthropic\");\nassert_eq!(model.model_id(), \"claude-sonnet-4-5-20250929\");\nassert!(model.supports_image_input());\n# Ok(())\n# }\n```"
        },
        {
          "name": "::AnthropicLanguageModel::new",
          "line": 111,
          "signature": "pub fn new(config: AnthropicConfig) -> Result<Self, AnthropicError>;",
          "documentation": "Creates a new Anthropic language model from the given configuration.\n\n# Arguments\n\n* `config` - Configuration containing API key, model, and client settings.\n\n# Returns\n\nThe configured language model.\n\n# Errors\n\nReturns `AnthropicError::InvalidConfig` if the configuration is invalid\n(e.g., empty API key).\n\n# Examples\n\n```no_run\nuse forge_provider_anthropic::{AnthropicLanguageModel, AnthropicConfig};\n\nlet config = AnthropicConfig::new(\"sk-ant-api03-...\");\nlet model = AnthropicLanguageModel::new(config);\nassert!(model.is_ok());\n```"
        },
        {
          "name": "::convert_tool_definition",
          "line": 623,
          "signature": "pub fn convert_tool_definition(tool: &ToolDefinition) -> AnthropicToolDef;",
          "documentation": "Converts Forge `ToolDefinition` to Anthropic `AnthropicToolDef`.\n\nThe key difference is that Anthropic uses `input_schema` where OpenAI\nuses `parameters`.\n\n# Arguments\n\n* `tool` - The Forge tool definition to convert.\n\n# Returns\n\nThe Anthropic tool definition."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/sse.rs",
      "sha256": "7b27a84ebf6b5086ff3d5347dd9e7ed6f29c85977a4c3b9eb3e7d9eba2392f53",
      "artifactSha256": "fe23d922c6d5e3bc187bb523267d2a3d3a2e93932194697678387ea3cb2b6ab7",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/sse.rs.txt",
      "declarations": [
        {
          "name": "::AnthropicSseEvent",
          "line": 30,
          "signature": "#[derive(Debug, Clone)]\npub enum AnthropicSseEvent {\n    /// Stream started with message metadata.\n    MessageStart {\n        /// Input token count from the initial message.\n        input_tokens: u64,\n    },\n    /// A new content block started.\n    ContentBlockStart {\n        /// Zero-based index of this block.\n        index: u32,\n        /// The initial content block.\n        block: ContentBlock,\n    },\n    /// Incremental update to the current content block.\n    ContentBlockDelta {\n        /// Zero-based index of the block being updated.\n        index: u32,\n        /// The delta update.\n        delta: DeltaBlock,\n    },\n    /// A content block finished.\n    ContentBlockStop {\n        /// Zero-based index of the completed block.\n        index: u32,\n    },\n    /// Stream metadata update (stop reason, output usage).\n    MessageDelta {\n        /// Why generation stopped.\n        stop_reason: Option<String>,\n        /// Output tokens generated.\n        output_tokens: Option<u64>,\n    },\n    /// Stream completed.\n    MessageStop,\n    /// Keepalive ping (ignored by consumers).\n    Ping,\n}",
          "documentation": "Parsed SSE event from the Anthropic stream.\n\nThese are intermediate representations; the [`crate::model`] module converts\nthem into Forge `StreamChunk` values."
        },
        {
          "name": "::parse_sse_stream",
          "line": 84,
          "signature": "pub fn parse_sse_stream(sse_bytes: &[u8]) -> Result<Vec<StreamChunk>, AnthropicError>;",
          "documentation": "Parses a raw SSE byte stream into Forge `StreamChunk` values.\n\nThis function processes the complete SSE response body (collected after\nthe HTTP response completes) and returns a vector of `StreamChunk`.\n\n# Arguments\n\n* `sse_bytes` - The raw SSE response body bytes.\n\n# Returns\n\nA vector of `StreamChunk` representing the streamed response.\n\n# Errors\n\nReturns `AnthropicError::SseParseFailed` if an SSE event cannot be parsed."
        },
        {
          "name": "::SseDecoder",
          "line": 324,
          "signature": "pub struct SseDecoder {\n\n}",
          "documentation": "Stateful SSE decoder for incremental byte streams.\n\nBuffers partial events across `feed(&[u8])` calls and yields complete\nevents via `drain()`. Tolerates byte-chunk boundaries that split SSE\nevents at any point \u2014 between lines, mid-line in a `data:` JSON value,\nor mid-`event:` header. The only correctness guarantee from upstream is\nthat SSE line terminators (`\\n` or `\\r\\n`) appear at byte boundaries\nwhere the producer wrote them.\n\n# Examples\n\n```\nuse forge_provider_anthropic::sse::{AnthropicSseEvent, SseDecoder};\n\nlet mut decoder = SseDecoder::new();\n// Bytes can arrive in any chunking \u2014 feed them in pieces:\ndecoder.feed(b\"event: ping\\ndata: {}\\n\\n\").unwrap();\nlet events = decoder.drain();\nassert_eq!(events.len(), 1);\nassert!(matches!(events[0], AnthropicSseEvent::Ping));\n```"
        },
        {
          "name": "::SseDecoder::new",
          "line": 338,
          "signature": "pub fn new() -> Self;",
          "documentation": "Creates a new, empty decoder."
        },
        {
          "name": "::SseDecoder::feed",
          "line": 355,
          "signature": "pub fn feed(&mut self, bytes: &[u8]) -> Result<(), AnthropicError>;",
          "documentation": "Feeds raw bytes into the decoder. Any complete events that become\navailable are queued; call [`drain`](Self::drain) to take them.\n\n# Errors\n\nReturns `AnthropicError::SseParseFailed` if a complete event's JSON\npayload fails to deserialize into the expected event type. Partial\nevents (still waiting for more bytes) never error here."
        },
        {
          "name": "::SseDecoder::drain",
          "line": 413,
          "signature": "pub fn drain(&mut self) -> Vec<AnthropicSseEvent>;",
          "documentation": "Drains all events ready to be consumed."
        },
        {
          "name": "::SseDecoder::finish",
          "line": 428,
          "signature": "pub fn finish(&mut self) -> Result<Vec<AnthropicSseEvent>, AnthropicError>;",
          "documentation": "Signals end-of-stream, flushing any pending partial event.\n\nSSE streams are typically terminated by an explicit `message_stop`\nevent followed by an empty line, but if the upstream connection\ncloses without that final blank line, this method ensures the last\nevent still gets parsed.\n\n# Errors\n\nSame as [`feed`](Self::feed) \u2014 returns an error if the final\npending event's JSON payload fails to deserialize."
        },
        {
          "name": "::ChunkEmitter",
          "line": 476,
          "signature": "pub struct ChunkEmitter {\n\n}",
          "documentation": "Stateful event-to-chunk converter.\n\nThreads the cross-event state that `parse_sse_stream` previously held\nlocally (input/output token totals, tool-block JSON accumulators, final\nstop reason) so events can be processed one at a time as they arrive\nfrom [`SseDecoder`].\n\n# Examples\n\n```no_run\nuse forge_provider_anthropic::sse::{AnthropicSseEvent, ChunkEmitter, SseDecoder};\n\n# fn example(bytes: &[u8]) -> Result<Vec<forge_core::output::StreamChunk>, forge_provider_anthropic::error::AnthropicError> {\nlet mut decoder = SseDecoder::new();\nlet mut emitter = ChunkEmitter::new();\nlet mut chunks = Vec::new();\n\ndecoder.feed(bytes)?;\nfor event in decoder.drain() {\n    chunks.extend(emitter.emit(event));\n}\nOk(chunks)\n# }\n```"
        },
        {
          "name": "::ChunkEmitter::new",
          "line": 486,
          "signature": "pub fn new() -> Self;",
          "documentation": "Creates a fresh emitter for one stream."
        },
        {
          "name": "::ChunkEmitter::emit",
          "line": 496,
          "signature": "pub fn emit(&mut self, event: AnthropicSseEvent) -> Vec<StreamChunk>;",
          "documentation": "Converts one event into zero or more `StreamChunk` values."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-anthropic/src/types.rs",
      "sha256": "5364c9d915a47924d75808cdfb24da70231824159de94b95894f6d1adb2b1852",
      "artifactSha256": "f818cc60c3555986ffb3e027a367a1ccb017a7a7f8d83020cd39091d22812185",
      "url": "/reference/source/forge-rs/crates/forge-provider-anthropic/src/types.rs.txt",
      "declarations": [
        {
          "name": "::MessagesRequest",
          "line": 27,
          "signature": "#[derive(Debug, Clone, Serialize)]\npub struct MessagesRequest {\n/// The model to use (e.g., \"claude-sonnet-4-5-20250929\").\n\npub model: String,\n/// The conversation messages. Must not contain system messages; use\n\n/// the `system` field instead.\n\npub messages: Vec<AnthropicMessage>,\n/// Top-level system prompt. Anthropic does not use a system role in\n\n/// the messages array.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub system: Option<String>,\n/// Maximum tokens to generate. Required by the Anthropic API.\n\npub max_tokens: u32,\n/// Tool definitions available to the model.\n\n#[serde(skip_serializing_if = \"Vec::is_empty\")]\npub tools: Vec<AnthropicToolDef>,\n/// Sampling temperature (0.0..1.0).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub temperature: Option<f64>,\n/// Top-p (nucleus) sampling threshold.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub top_p: Option<f64>,\n/// Stop sequences.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub stop_sequences: Option<Vec<String>>,\n/// Whether to stream the response via SSE.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub stream: Option<bool>\n}",
          "documentation": "A request to the Anthropic Messages API (`POST /messages`).\n\nSee <https://docs.anthropic.com/en/api/messages> for the full specification."
        },
        {
          "name": "::AnthropicMessage",
          "line": 69,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct AnthropicMessage {\n/// The message role: \"user\" or \"assistant\".\n\npub role: String,\n/// Content blocks making up the message.\n\npub content: Vec<ContentBlock>\n}",
          "documentation": "A single message in the Anthropic conversation format.\n\nAnthropic messages have a role (\"user\" or \"assistant\") and an array of\ntyped content blocks. System messages are NOT placed here."
        },
        {
          "name": "::ContentBlock",
          "line": 83,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\n#[serde(tag = \"type\", rename_all = \"snake_case\")]\npub enum ContentBlock {\n    /// A text content block.\n    Text {\n        /// The text content.\n        text: String,\n    },\n\n    /// A tool use (tool call) content block \u2014 returned by the model.\n    ToolUse {\n        /// Unique identifier for this tool use.\n        id: String,\n        /// The tool name.\n        name: String,\n        /// The input arguments as a JSON object.\n        input: serde_json::Value,\n    },\n\n    /// A tool result content block \u2014 sent by the client after executing a tool.\n    ToolResult {\n        /// The `tool_use` ID this result corresponds to.\n        tool_use_id: String,\n        /// The result content.\n        content: String,\n        /// Whether the tool execution resulted in an error.\n        #[serde(skip_serializing_if = \"Option::is_none\")]\n        is_error: Option<bool>,\n    },\n\n    /// An image content block.\n    Image {\n        /// The image source.\n        source: ImageSource,\n    },\n}",
          "documentation": "A typed content block within an Anthropic message.\n\nContent blocks are tagged by their `type` field. The Anthropic API\nuses these both in requests and responses."
        },
        {
          "name": "::ImageSource",
          "line": 122,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ImageSource {\n/// The source type \u2014 always \"base64\" for inline images.\n\n#[serde(rename = \"type\")]\npub source_type: String,\n/// The MIME type (e.g., \"image/png\", \"image/jpeg\").\n\npub media_type: String,\n/// The base64-encoded image data.\n\npub data: String\n}",
          "documentation": "Image source for the Anthropic API.\n\nSupports base64-encoded images with a media type."
        },
        {
          "name": "::AnthropicToolDef",
          "line": 136,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct AnthropicToolDef {\n/// The tool name.\n\npub name: String,\n/// Human-readable description.\n\npub description: String,\n/// JSON Schema for the tool's input parameters.\n\npub input_schema: serde_json::Value\n}",
          "documentation": "An Anthropic tool definition.\n\nAnthropic uses `input_schema` instead of OpenAI's `parameters`."
        },
        {
          "name": "::MessagesResponse",
          "line": 151,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct MessagesResponse {\n/// Unique message identifier (e.g., \"msg_01XFDUDYJgAACzvnptvVoYEL\").\n\npub id: String,\n/// Object type \u2014 always \"message\".\n\n#[serde(rename = \"type\")]\npub object_type: String,\n/// The role \u2014 always \"assistant\" for responses.\n\npub role: String,\n/// The response content blocks (text, tool_use).\n\npub content: Vec<ContentBlock>,\n/// The model that generated the response.\n\npub model: String,\n/// Why generation stopped: \"end_turn\", \"max_tokens\", \"tool_use\", \"stop_sequence\".\n\npub stop_reason: Option<String>,\n/// Token usage statistics.\n\npub usage: AnthropicUsage\n}",
          "documentation": "Response from the Anthropic Messages API (non-streaming)."
        },
        {
          "name": "::AnthropicUsage",
          "line": 177,
          "signature": "#[derive(Debug, Clone, Copy, Deserialize, Serialize)]\npub struct AnthropicUsage {\n/// Number of input (prompt) tokens.\n\npub input_tokens: u64,\n/// Number of output (completion) tokens.\n\npub output_tokens: u64\n}",
          "documentation": "Token usage statistics from the Anthropic API."
        },
        {
          "name": "::AnthropicApiErrorResponse",
          "line": 188,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct AnthropicApiErrorResponse {\n/// The error type (e.g., \"invalid_request_error\").\n\n#[serde(rename = \"type\")]\npub error_type: String,\n/// The error details.\n\npub error: AnthropicApiErrorDetail\n}",
          "documentation": "An error response from the Anthropic API.\n\nReturned when the API responds with a non-2xx status code."
        },
        {
          "name": "::AnthropicApiErrorDetail",
          "line": 198,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct AnthropicApiErrorDetail {\n/// The error type (e.g., \"invalid_request_error\").\n\n#[serde(rename = \"type\")]\npub error_type: String,\n/// Human-readable error message.\n\npub message: String\n}",
          "documentation": "The nested error detail within an Anthropic error response."
        },
        {
          "name": "::MessageStartEvent",
          "line": 214,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct MessageStartEvent {\n/// The message response metadata.\n\npub message: MessagesResponse\n}",
          "documentation": "The `message_start` SSE event payload.\n\nContains the initial `MessagesResponse` with empty content."
        },
        {
          "name": "::ContentBlockStartEvent",
          "line": 223,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct ContentBlockStartEvent {\n/// The zero-based index of this content block.\n\npub index: u32,\n/// The initial content block (may have empty text or partial tool_use).\n\npub content_block: ContentBlock\n}",
          "documentation": "The `content_block_start` SSE event payload.\n\nIndicates a new content block is starting in the stream."
        },
        {
          "name": "::ContentBlockDeltaEvent",
          "line": 234,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct ContentBlockDeltaEvent {\n/// The zero-based index of the content block being updated.\n\npub index: u32,\n/// The delta update.\n\npub delta: DeltaBlock\n}",
          "documentation": "The `content_block_delta` SSE event payload.\n\nContains incremental updates to the current content block."
        },
        {
          "name": "::DeltaBlock",
          "line": 246,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\n#[serde(tag = \"type\", rename_all = \"snake_case\")]\npub enum DeltaBlock {\n    /// Incremental text content.\n    TextDelta {\n        /// The text fragment.\n        text: String,\n    },\n    /// Incremental JSON for tool use input.\n    InputJsonDelta {\n        /// A fragment of the JSON input string.\n        partial_json: String,\n    },\n}",
          "documentation": "A delta block within a `content_block_delta` event.\n\nCan be a text delta or an input JSON delta (for tool use streaming)."
        },
        {
          "name": "::MessageDeltaEvent",
          "line": 263,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct MessageDeltaEvent {\n/// The delta with the stop reason.\n\npub delta: MessageDelta,\n/// Updated usage statistics.\n\npub usage: Option<MessageDeltaUsage>\n}",
          "documentation": "The `message_delta` SSE event payload.\n\nContains the final `stop_reason` and usage update."
        },
        {
          "name": "::MessageDelta",
          "line": 272,
          "signature": "#[derive(Debug, Clone, Deserialize)]\npub struct MessageDelta {\n/// Why generation stopped: \"end_turn\", \"max_tokens\", \"tool_use\", \"stop_sequence\".\n\npub stop_reason: Option<String>\n}",
          "documentation": "The delta portion of a `message_delta` event."
        },
        {
          "name": "::MessageDeltaUsage",
          "line": 282,
          "signature": "#[derive(Debug, Clone, Copy, Deserialize)]\npub struct MessageDeltaUsage {\n/// The output tokens generated so far.\n\npub output_tokens: u64\n}",
          "documentation": "Usage statistics from a `message_delta` event.\n\nOnly contains `output_tokens` because input tokens were reported in\n`message_start`."
        }
      ]
    }
  ]
}
