Skip to main content

Installation

Add openmodex to your Cargo.toml:
Requires Rust 2021 edition (1.56+). The SDK uses tokio for async and reqwest for HTTP.

Quick Start

You can also create a client from the OPENMODEX_API_KEY environment variable using OpenModex::from_env()?.

Configuration

Use ClientBuilder for advanced configuration:

Chat Completions

Streaming

The SDK returns a ChatCompletionStream that implements futures::Stream:

Embeddings

Models

Smart Routing

Configure per-request routing with the OpenModex routing extension:

Cache Control

Enable prompt caching per request:

Fallbacks

Configure client-level fallbacks that activate automatically on failures (5xx, 429, or network errors):

Error Handling

OpenAI Compatibility

Already using the OpenAI API with reqwest? You can point to OpenModex by changing the base URL:
The OpenModex API is fully compatible with the OpenAI API format. All standard parameters like temperature, max_tokens, top_p, stop, tools, tool_choice, and response_format work as expected.