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::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_result_message;pub use tools::tool_result_message_json;pub use tools::BoxFuture;pub use tools::ParseResult;pub use tools::ResponseExt;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;pub use types::Citation;pub use types::MessageRole;pub use generated::DeviceStartResponse;pub use customers::SubscriptionStatus;pub use generated::RunsPendingToolCallV0;pub use generated::RunsPendingToolsNodeV0;pub use generated::RunsPendingToolsResponse;pub use identifiers::TierCode;pub use workflow::ModelId;pub use workflow::NodeErrorV0;pub use workflow::NodeId;pub use workflow::NodeStatusV0;pub use workflow::PlanHash;pub use workflow::ProviderId;pub use workflow::RequestId;pub use workflow::RunCostLineItemV0;pub use workflow::RunCostSummaryV0;pub use workflow::RunId;pub use workflow::RunStatusV0;pub use workflow::Sha256Hash;pub use token_providers::CustomerTokenResponse;
Modules§
- generated
- Generated types from OpenAPI spec.
Run
just generate-sdk-typesto regenerate from api/openapi/api.yaml. Auto-generated types from OpenAPI spec. - 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
- Structured error envelope returned by the API.
- APIKey
- Representation of an API key record.
- Artifact
Key - Artifact key type for node outputs and run outputs.
- Attempt
Record - Record of a single structured output attempt.
- Auth
Client - Async client for customer token operations.
- Checkout
Session - Checkout session response.
- Checkout
Session Request - Request to create a checkout session.
- Client
- Async client for the ModelRelay API.
- Client
Builder - Builder for constructing a
Clientwith explicit configuration. - Code
Exec Config - Code execution configuration.
- Config
- Configuration for the async ModelRelay client.
- Customer
- A customer in a ModelRelay project.
- Customer
Claim Request - Request to link an end-user identity (provider + subject) to a customer by email.
- Customer
Create Request - Request to create a customer.
- Customer
Token - Short-lived bearer token usable from browser/mobile clients.
- Customer
Token Request - Request payload for POST /auth/customer-token.
- Customer
Upsert Request - Request to upsert a customer by external_id.
- Customers
Client - Client for customer management operations.
- Date
Time - ISO 8601 combined date and time with time zone.
- Default
Retry Handler - Default retry handler that appends a simple error correction message.
- Device
Auth Config - Configuration for starting OAuth device authorization.
- Device
Authorization - Result of device authorization request.
- Device
Poll Config - Configuration for polling the device token endpoint.
- Device
Start Request - Request options for starting a device authorization flow.
- Device
Token - Result of successful device token poll.
- Device
Token Pending - Pending state when user hasn’t completed authorization yet.
- Device
Token Response - Successful token response from device flow.
- EdgeV0
- An edge connecting two nodes in the workflow DAG.
- Execution
V0 - Execution configuration for a workflow.
- Field
Error - Field-level validation error returned by the API.
- Function
Call - Function call details in a tool call.
- Function
Call Delta - Incremental function call data.
- Function
Tool - Function tool definition.
- Header
Entry - Header
List - Structured header/metadata list with validation.
- Http
Request Metrics - HTTP request latency and outcome.
- JSON
Schema Format - JSON schema payload for structured outputs.
- LlmResponses
Binding V0 - Metrics
Callbacks - User-provided callbacks for emitting metrics without taking on a tracing dependency.
- Model
- Model identifier (string wrapper).
- Models
Client - Client for model catalog operations.
- Node
Result V0 - Result of a completed node.
- NodeV0
- A node in the workflow DAG.
- OIDC
Exchange Config - Configuration for
OIDCExchangeTokenProvider. - OIDC
Exchange Token Provider - Token provider that exchanges OIDC id_tokens for customer bearer tokens.
- Output
Format - Output format configuration (structured outputs).
- Output
RefV0 - Reference to a workflow output.
- Payload
Info V0 - Metadata about a payload (node output or run outputs).
- Publishable
Key - Request
Context - Common request metadata shared by all telemetry events.
- Response
- Aggregated response returned by
POST /responses. - Response
Builder - Builder for
POST /responses(async). - Response
Options - Optional headers for
POST /responsescalls. - Response
Stream Adapter - Adapter that yields only text deltas from a stream handle.
- Responses
Client - Async client for
POST /responses. - Retry
Config - Retry/backoff configuration (defaults use 3 attempts + jittered exponential backoff).
- Retry
Metadata - Retry metadata surfaced on transport/API errors when retries were attempted.
- RunEvent
Envelope - Common envelope fields for all run events.
- RunEvent
Stream Handle streaming - RunEvent
V0 - A run event with envelope metadata and payload.
- Runs
Client - Runs
Create Response - Runs
GetResponse - Secret
Key - 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 streaming - Streaming handle over NDJSON response events.
- Structured
Decode Error - Error returned when structured output fails on first attempt (before retries).
- Structured
Exhausted Error - Error returned when all retry attempts are exhausted.
- StructuredJSON
Event - Structured JSON event (parsed from NDJSON envelope).
- StructuredJSON
Stream streaming - Helper over NDJSON streaming events to yield structured JSON payloads.
- Structured
Options - Options for structured output requests.
- Structured
Result - Result of a successful structured output request.
- Tier
- Tier
Checkout Request - Request to create a tier checkout session (Stripe-first flow). Stripe collects the customer’s email during checkout.
- Tier
Checkout Session - Tier checkout session response.
- Tier
Model - A pricing tier in a ModelRelay project.
- Tiers
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.
- Transform
Json Input V0 - Transform
Json Value V0 - Transport
Error - Transport-level error (timeouts, DNS/TLS/connectivity).
- Usage
- Token usage metadata.
- Usage
Summary - Utc
- The UTC time zone. This is the most efficient time zone when you don’t need the local time. It is also used as an offset (which is also a dummy type).
- Uuid
- A Universally Unique Identifier (UUID).
- Validation
Error - Structured validation/build error returned by the SDK.
- Validation
Issue - A single field-level validation issue.
- WebTool
Config - Web tool configuration.
- Workflow
Builder V0 - Workflow
Spec V0 - Workflow specification (v0).
- Workflow
Validation Error - Typed workflow validation error surfaced by the SDK.
- Workflow
Validation Issue - Workflow semantic validation error returned by the API compiler (
/workflows/compile). - Workflows
Client - Workflows
Compile Response V0 - XSearch
Config - X/Twitter search configuration.
Enums§
- ApiKey
- Content
Part - Content part within a message (currently only
text). - Device
Flow Error Kind - Typed error kinds for device flow failures.
- Device
Flow Provider - Provider for native device authorization flow.
- Device
Token Result - Result of polling the device token endpoint.
- Envelope
Version - Envelope version for run events. Schema specifies const “v0”.
- Error
- Unified error type surfaced by the SDK.
- Input
Item - Input item sent to
/responses. - LlmResponses
Binding Encoding V0 - Node
Type V0 - Node type within a workflow.
- Output
Format Kind - Supported output format types.
- Output
Item - Output item returned by
/responses. - Price
Interval - Billing interval for a tier.
- RunEvent
Payload - Event-specific payload data.
- RunEvent
Type V0 - Run event type discriminator.
- Stop
Reason - Stop reason returned by the backend and surfaced by
/responses. - Stream
Event Kind - High-level streaming event kinds emitted by the API.
- Structured
Error - Unified error type for structured output operations.
- Structured
Error Kind - Specific kind of structured output error.
- Structured
Record Kind - Kind of structured record.
- Subscription
Status Kind - Subscription status values (matches Stripe subscription statuses).
- Tool
Choice Type - Tool choice type.
- Tool
Type - Tool type identifiers.
- Transport
Error Kind - Broad transport error kinds for classification.
- Workflow
Kind - Workflow specification version.
- Workflows
Compile Result V0
Constants§
- CUSTOMER_
ID_ HEADER - HTTP header name for customer-attributed requests.
- DEFAULT_
BASE_ URL - Default API base URL.
- DEFAULT_
CONNECT_ TIMEOUT - Default connection timeout (5 seconds).
- DEFAULT_
REQUEST_ TIMEOUT - Default request timeout (60 seconds).
- REQUEST_
ID_ HEADER - HTTP header name for request ID tracing.
- RUN_
EVENT_ V0_ SCHEMA_ JSON - JSON Schema for run_event.v0 events.
- WORKFLOW_
V0_ SCHEMA_ JSON - JSON Schema for workflow.v0 specifications.
Traits§
- Message
Role Ext - Extension trait for MessageRole providing convenience methods.
- Retry
Handler - Handler for customizing retry behavior on validation failures.
- Token
Provider - Trait for token providers that supply bearer tokens for API requests.
Functions§
- output_
format_ from_ type - Generates an
OutputFormatwith automatic JSON schema from a type. - poll_
device_ token - Poll for OAuth device token until authorized or timeout.
- run_
device_ flow_ for_ id_ token - Run complete OAuth device flow and return the id_token.
- run_
node_ ref - Creates a reference string for a node within a run.
- start_
device_ authorization - Start OAuth device authorization flow.
- workflow_
v0
Type Aliases§
- Catalog
Model - CatalogModel is the model catalog entry returned by GET /models.
- Customer
Metadata - Customer metadata as a key-value map.
- IdToken
Source - Type alias for async id_token provider functions.