llm-relay
Shared Rust crate for LLM API types, format conversion, and HTTP client. Uses Anthropic as the canonical internal format and converts at the API boundary.
Features
- Anthropic & OpenAI types — typed content blocks, tool use, extended thinking, embeddings
- Bidirectional conversion — Anthropic <-> OpenAI format (messages, tools, responses)
- HTTP client — chat completions (both providers) and embeddings
- Extended thinking — adaptive thinking (Opus 4.6, Sonnet 4.6) and manual budget mode
- Proxy utilities — cache control injection, MCP tool name transforms
Cargo features
| Feature | Default | Description |
|---|---|---|
client |
yes | HTTP client (reqwest + thiserror) |
embeddings |
no | Embeddings client (implies client) |
Use default-features = false for types and conversion only (no HTTP dependencies).
Usage
use ;
use Message;
let client = new?;
// Simple text completion
let response = client.complete.await?;
// Full chat with tools and thinking
let messages = vec!;
let options = ChatOptions ;
let response = client.chat.await?;
Types-only (for proxy/conversion scenarios):
// Cargo.toml: llm-relay = { path = "...", default-features = false }
use inbound_request_to_anthropic;
use anthropic_response_to_openai;
use InboundChatRequest;