rig
/rig
Prowadzi przez budowę klientów LLM w Rust z biblioteką rig: AgentBuilder, dostawcy modeli, narzędzia, extractory, RAG i streaming, także z modelami lokalnymi.
- Autor
- vinnie357 ↗
- Repozytorium
- claude-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 6
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 07.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Prowadzi przez budowę klientów LLM w Rust z biblioteką rig: AgentBuilder, dostawcy modeli, narzędzia, extractory, RAG i streaming, także z modelami lokalnymi.
Oryginalny opis (EN)
Guide for building LLM clients in Rust with rig (rig-core) — AgentBuilder, providers, tools, extractors, RAG, and streaming. Use when writing Rust LLM clients with rig or rig-core, building multi-provider or hybrid clients that mix Anthropic, OpenAI, Gemini, or local models, integrating ollama, LM Studio, or an OpenAI-compatible gateway (LiteLLM, Bifrost, Lemonade Server) from Rust, or implementing rig agents, tools, extractors, or RAG pipelines.
Jak działa
- Setup
- AgentBuilder quickstart
- Hybrid multi-provider harness
- 12-factor model configuration
- Reference map
- Adversarial TDD
- Anti-fabrication
Podgląd SKILL.md
---
name: rig
description: Guide for building LLM clients in Rust with rig (rig-core) — AgentBuilder, providers, tools, extractors, RAG, and streaming. Use when writing Rust LLM clients with rig or rig-core, building multi-provider or hybrid clients that mix Anthropic, OpenAI, Gemini, or local models, integrating ollama, LM Studio, or an OpenAI-compatible gateway (LiteLLM, Bifrost, Lemonade Server) from Rust, or implementing rig agents, tools, extractors, or RAG pipelines.
license: MIT
---
# Rig
Rig (crate `rig-core`) is a Rust library for building LLM-powered applications: provider
clients, agents with tools, structured extractors, RAG pipelines, and streaming completions.
This skill covers `rig-core` 0.40.0, workspace edition 2024, repo-pinned toolchain 1.94.0.
## Setup
```bash
cargo add rig-core
```
Feature flags relevant to agent work:
- `derive` — enables the `rig-derive` macros (schema derivation for tool/extractor types)
- `rmcp` — enables MCP (Model Context Protocol) tool integration via the `rmcp` crate
```toml
[dependencies]
rig-core = { version = "0.40", features = ["rmcp"] }
```
`derive` and `reqwest`/`rustls` ship in rig-core's default feature set; add `rmcp` explicitly
for MCP tools.
## AgentBuilder quickstart
Every provider client exposes `.agent(model)`, returning an `AgentBuilder`:
```rust
use rig_core::prelude::*;
use rig_core::providers::anthropic;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = anthropic::Client::from_env()?;
let agent = client
.agent(anthropic::completion::CLAUDE_SONNET_4_6)
.preamble("Answer concisely.")
.temperature(0.0)
.build();
let answer = agent.prompt("What is Rig?").await?;
println!("{answer}");
Ok(())
}
```
`from_env()` reads provider credentials from environment variables — no API key touches
application code. `.agent()` takes `impl Into<String>` for the model argument: a provider
module constant (`anthropic::completion::CLAUDE_SONNET_4_6`) or a raw string both work. See
`references/providers.md` for the constants available per provider and the env-var contract
each `from_env()` reads.
## Hybrid multi-provider harness
A single Rust process commonly needs several models at once — a cheap model for extraction,
a mid-tier model for the main loop, a strong model for review, one of them local. Rig
provides the primitives (clients, `AgentBuilder`, the `CompletionModel` trait) — it does not
ship a built-in multi-tier harness type. The tier-selection pattern in
`references/providers.md` is guidance built on those primitives, not a first-party rig
recipe.
The load-bearing constraint: `CompletionModel` is `Clone`-bound with no dyn-compatible
variant (no `Box<dyn CompletionModel>`, no `CompletionModelDyn`). Route between tiers with
enum dispatch over concrete `Agent<M>` types, generic functions bounded by
`M: CompletionModel`, or concrete per-tier fields on your own harness struct — never a
trait-object collection of agents. `references/providers.md` works through this with a
worked example spanning Anthropic, OpenAI, Gemini, and a local ollama tier.
## 12-factor model configuration
Read model IDs from environment variables, never hardcode them in application code:
```rust
let model_id = std::env::var("AGENT_MODEL").unwrap_or_else(|_| {
anthropic::completion::CLAUDE_HAIKU_4_5.to_string()
});
let agent = client.agent(model_id).build();
```
This applies per tier in a hybrid harness — `AGENT_FAST_MODEL`, `AGENT_MAIN_MODEL`,
`AGENT_REVIEW_MODEL`, or equivalent names read at startup, not compiled in. Base URLs follow
the same rule: `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`, `OLLAMA_API_BASE_URL` are read by
`from_env()` directly, or set explicitly via `ClientBuilder::base_url()` when a config value
comes from somewhere other than the environment.
## Reference map
- `references/providers.md` — per-provider client construction, env vars, model-ID strings
vs constants, and the worked multi-provider/hybrid-tier harness example
- `references/local-and-gateways.md` — ollama (built-in), remote ollama, LM Studio, LiteLLM,
Bifrost, and Lemonade Server via the OpenAI-compatible client + base URL, and the
local-model typed tool-args gotcha
- `references/agents-tools.md` — full `AgentBuilder` surface, the `Tool` trait, extractors,
and MCP integration via the `rmcp` feature
- `references/rag-embeddings.md` — `EmbeddingModel`, vector-store companion crates, and the
RAG agent pattern
- `references/streaming.md` — streaming completions
## Adversarial TDD
When implementing rig code under adversarial TDD, the `rust` plugin's
`rust-test-author`/`rust-implementer` pair applies unchanged — load this skill into both
workers. This skill is fully usable on its own without that pair.
## Anti-fabrication
This skill follows `core:anti-fabrication`. Every client construction pattern, trait bound,
and constant cited here is verified against the `rig-core` 0.40.0 source tree (see
`sources.md`) — not inferred from training-data familiarity with an earlier rig version.
Before asserting a trait signature or constant this skill and its references do not cover,
check the installed `rig-core` version's source or docs.rs rather than guessing.
Pliki w paczce (6)
- SKILL.md 5 KB
- references/agents-tools.md 6 KB
- references/local-and-gateways.md 4 KB
- references/providers.md 6 KB
- references/rag-embeddings.md 2 KB
- references/streaming.md 1 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · vinnie357/claude-skills | 100 | MIT |
| sectersion/anyctl | 100 | MIT |
| slamb2k/mad-skills | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 33f0aa480f38 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 96hermes-rig
Uruchamia, obserwuje i zatrzymuje miejsca OpenRig przez narzędzie rig. - 100openai-agents-sdk
Wspiera tworzenie agentów w Pythonie z pakietem openai-agents: przekazania między agentami, narzędzia funkcyjne, guardrails, sesje, streaming i tracing, także przez Azure OpenAI lub LiteLLM. - 100rust-agentai
Buduje agentów AI w Rust z biblioteką agentai: narzędzia, wyjście strukturalne i serwery MCP, także z crate genai. - 100local-ai-app-integration
Wbudowuje lokalne AI w aplikacje przez Embeddable Lemonade: lokalny LLM, czat, embeddingi, obrazy, rozpoznawanie i synteza mowy oraz zastępowanie chmurowych API OpenAI, Anthropic czy Ollama. - 90llm-app-guardrails
Pilnuje zasad w kodzie, który wywołuje LLM: prompty, RAG, wyszukiwanie wektorowe, narzędzia agentów i wyjście strukturalne. - 90ai-llm-patterns
Opisuje wzorce integracji AI: strumieniowanie w SDK Anthropic, RAG z pgvector, wywołania narzędzi, dobór modelu i koszty tokenów.