Skip to main content
Rig is a Rust library for building LLM apps and agents. As of Rig 0.42 it ships a first-party venice provider — chat completions, streaming, tools, structured output, embeddings, transcription, image generation, and speech — wired to Venice’s API rather than tunneled through the OpenAI client. If you want a raw Axum proxy instead of an agent framework, see Building a Rust LLM Gateway.

Prerequisites

  • A recent stable Rust toolchain (Rig 0.42 uses edition 2024)
  • Rig 0.42 or later
  • A Venice API key

Setup

Add your Venice API key to the environment. Optionally override the API host with VENICE_BASE_URL (the provider defaults to https://api.venice.ai/api/v1):
Keep API keys out of source control. Prefer environment variables or a secret manager in production.

Configure the Venice client

venice::Client::from_env() reads VENICE_API_KEY. Bring ProviderClient into scope:
Prefer venice::Client over pointing Rig’s OpenAI client at Venice. The default openai::Client targets OpenAI’s Responses API. The Venice provider speaks /chat/completions and exposes VeniceParameters.
The snippets below take a &venice::Client from from_env(). Crate constants such as venice::QWEN3_5_9B are a starting point — confirm current IDs with GET /models.

Stream a response

stream_prompt returns a request that you .await into a stream. Use rig::agent::stream_to_stdout to print tokens as they arrive:
Do not add ? after .await on stream_prompt — it yields the stream directly, not a Result.

Structured output

Use an extractor with a JsonSchema type to validate the model’s answer:
Browse models that support structured responses and function calling before relying on tool-based extraction in production.

Tools

Define a tool with #[rig_tool] (included with Rig’s default derive feature). The generated type is the function name in PascalCase:
You can also implement rig::tool::Tool by hand when you need custom argument types or error handling. See Rig’s tool docs.

Embeddings

Venice honors OpenAI’s dimensions field. Use embedding_model_with_ndims when you want a specific width rather than the model’s native size.

Venice-specific parameters

Pass Venice-only options through VeniceParameters and merge them with additional_params. For example, enable built-in web search:
To keep web-search citations (and the per-request cost block), call raw_completion on the completion model. The normalized agent path drops those Venice-only fields:
VeniceParameters also covers character slugs, thinking controls, web scraping, X search, and whether to include Venice’s default system prompt. See the API specification for the full venice_parameters list.

Other capabilities

The same venice::Client also drives:
  • Transcriptionclient.transcription_model(venice::WHISPER_LARGE_V3)
  • Image generationclient.image_generation_model(...) (enable Rig’s image feature)
  • Speechclient.audio_generation_model(venice::TTS_KOKORO) (enable Rig’s audio feature)
Video, music, image editing, /augment/*, and crypto RPC have no Rig trait and are not wrapped. Call those Venice endpoints directly.

Privacy advantage

Rig is often used for agents that touch application data, user context, or internal tools. Pairing it with Venice keeps that workflow on private, uncensored inference:
  • Zero data retention on private models — prompts and tool payloads are not kept after the request
  • Uncensored analysis when agents need blunt critique or red-teaming
  • A first-party provider so you are not remapping OpenAI types onto Venice’s dialect

Troubleshooting

Confirm VENICE_API_KEY is set in the process that runs the agent. Restart the shell or process after changing environment variables. from_env() does not read OPENAI_API_KEY.
Use a current model ID from the models page or GET /models. Crate constants such as venice::QWEN3_5_9B can lag the live catalog.
Use venice::Client, not openai::Client. The OpenAI client defaults to the Responses API, which is only alpha on Venice.
Pick a model that supports function calling, describe when tools should run in the preamble, and keep tool descriptions precise — Rig builds JSON schemas from #[rig_tool] signatures and docs.

Rig Docs

Agents, tools, extractors, and providers

Venice Models

Browse models and supported capabilities