Expand description
Minimal Rust SDK for the ModelRelay API.
Re-exports§
pub use tools::assistant_message_with_tool_calls;pub use tools::create_retry_messages;pub use tools::execute_with_retry;pub use tools::format_tool_error_for_model;pub use tools::function_tool;pub use tools::get_retryable_errors;pub use tools::has_retryable_errors;pub use tools::parse_and_validate_tool_args;pub use tools::parse_tool_args;pub use tools::respond_to_tool_call;pub use tools::respond_to_tool_call_json;pub use tools::sync_handler;pub use tools::tool_choice_auto;pub use tools::tool_choice_none;pub use tools::tool_choice_required;pub use tools::tool_result_message;pub use tools::tool_result_message_json;pub use tools::web_tool;pub use tools::BoxFuture;pub use tools::ParseResult;pub use tools::ProxyResponseExt;pub use tools::RetryOptions;pub use tools::ToolArgsError;pub use tools::ToolCallAccumulator;pub use tools::ToolExecutionResult;pub use tools::ToolHandler;pub use tools::ToolRegistry;pub use tools::UnknownToolError;pub use tools::ValidateArgs;pub use tools::function_tool_from_type;pub use tools::ToolSchema;
Modules§
- tools
- Tool helpers for ergonomic tool use with the ModelRelay API.
Macros§
- tool_
handler - Helper macro to create a tool handler from an async closure.
Structs§
- APIError
clientorblockingorstreaming - Structured error envelope returned by the API.
- APIKey
- Representation of an API key record.
- Attempt
Record client - Record of a single structured output attempt.
- Auth
Client client - Chat
Request Builder clientorblocking - Builder for LLM proxy chat requests (async + streaming).
- Chat
Stream Adapter streamingand (clientorblocking) - Thin adapter over streaming events to yield text deltas and final metadata.
- Checkout
Session client - Checkout session response.
- Checkout
Session Request client - Request to create a checkout session.
- Client
client - Client
Builder client - Builder for constructing a
Clientwith explicit configuration. - Code
Exec Config - Code execution configuration.
- Config
client - Customer
client - A customer in a ModelRelay project.
- Customer
Chat Request Builder clientorblocking - Builder for customer-attributed LLM proxy chat requests.
- Customer
Claim Request client - Request to claim a customer by email, setting their external_id.
- Customer
Create Request client - Request to create a customer.
- Customer
Proxy Request Body clientorblocking - Request body for customer-attributed proxy requests (no model field).
- Customer
Upsert Request client - Request to upsert a customer by external_id.
- Customers
Client client - Client for customer management operations.
- Default
Retry Handler client - Default retry handler that appends a simple error correction message.
- Field
Error clientorblockingorstreaming - Field-level validation error returned by the API.
- Frontend
Token - Short-lived bearer token usable from browser/mobile clients.
- Frontend
Token Auto Provision Request - Request payload for POST /auth/frontend-token with auto-provisioning.
- Frontend
Token Request - Request payload for POST /auth/frontend-token for an existing customer.
- Function
Call - Function call details in a tool call.
- Function
Call Delta - Incremental function call data.
- Function
Tool - Function tool definition.
- Header
Entry clientorblocking - Header
List clientorblocking - Structured header/metadata list with validation.
- Http
Request Metrics - HTTP request latency and outcome.
- LLMClient
client - Metrics
Callbacks - User-provided callbacks for emitting metrics without taking on a tracing dependency.
- Model
- Model identifier (string wrapper).
- Proxy
Message - A single chat turn used by the LLM proxy.
- Proxy
Options clientorblocking - Optional headers and metadata for proxy calls.
- Proxy
Request - Request payload for
/llm/proxy. - Proxy
Request Builder - Fluent builder for
ProxyRequest. - Proxy
Response - Aggregated response returned by
/llm/proxy. - Request
Context - Common request metadata shared by all telemetry events.
- Response
Format - Response format configuration for structured outputs.
- ResponseJSON
Schema - JSON schema payload for structured outputs.
- Retry
Config clientorblocking - Retry/backoff configuration (defaults use 3 attempts + jittered exponential backoff).
- Retry
Metadata clientorblockingorstreaming - Retry metadata surfaced on transport/API errors when retries were attempted.
- Stream
Event - Single SSE event emitted by the streaming proxy.
- Stream
First Token Metrics - Time from request start to the first streaming token/event.
- Stream
Handle clientandstreaming - Streaming handle over SSE chat events.
- Structured
Chat Builder client - Builder for structured output chat requests.
- Structured
Decode Error client - Error returned when structured output fails on first attempt (before retries).
- Structured
Exhausted Error client - Error returned when all retry attempts are exhausted.
- Structured
Options client - Options for structured output requests.
- Structured
Result client - Result of a successful structured output request.
- Subscription
Status client - Subscription status response.
- Tier
client - A pricing tier in a ModelRelay project.
- Tier
Checkout Request client - Request to create a tier checkout session (Stripe-first flow). Stripe collects the customer’s email during checkout.
- Tier
Checkout Session client - Tier checkout session response.
- Tiers
Client client - Client for tier querying operations.
- Token
Usage Metrics - Token usage surfaced once a request/stream finishes.
- Tool
- A tool available for the model to call.
- Tool
Call - A tool call made by the model.
- Tool
Call Delta - Incremental update to a tool call during streaming.
- Tool
Choice - Controls how the model responds to tool calls.
- Transport
Error clientorblockingorstreaming - Transport-level error (timeouts, DNS/TLS/connectivity).
- Usage
- Token usage metadata.
- Usage
Summary - Validation
Error clientorblockingorstreaming - Structured validation/build error returned by the SDK.
- Validation
Issue client - A single field-level validation issue.
- WebTool
Config - Web tool configuration.
- XSearch
Config - X/Twitter search configuration.
Enums§
- Error
clientorblockingorstreaming - Unified error type surfaced by the SDK.
- Message
Role - Message role in a chat conversation.
- Price
Interval client - Billing interval for a tier.
- Response
Format Kind - Supported response format types.
- Stop
Reason - Stop reason returned by the backend and surfaced by
/llm/proxy. - Stream
Event Kind - High-level streaming event kinds emitted by the API.
- Stream
Format clientorblocking - Streaming response framing.
- Structured
Error client - Unified error type for structured output operations.
- Structured
Error Kind client - Specific kind of structured output error.
- Token
Type - OAuth2 token type. Always “Bearer” for ModelRelay tokens.
- Tool
Choice Type - Tool choice type.
- Tool
Type - Tool type identifiers.
- Transport
Error Kind clientorblockingorstreaming - Broad transport error kinds for classification.
Constants§
- API_
KEY_ HEADER - CUSTOMER_
ID_ HEADER clientorblocking - Header name for customer ID attribution.
- DEFAULT_
BASE_ URL - DEFAULT_
CLIENT_ HEADER - DEFAULT_
CONNECT_ TIMEOUT - DEFAULT_
REQUEST_ TIMEOUT - REQUEST_
ID_ HEADER
Traits§
- Retry
Handler client - Handler for customizing retry behavior on validation failures.
Functions§
- response_
format_ from_ type client - Generates a
ResponseFormatwith automatic JSON schema from a type.
Type Aliases§
- Customer
Metadata client - Customer metadata as a key-value map.