Summary
This PR fixes the Rig quickstart setup so the install command matches the imports used in the example.
The docs currently install rig-core, but the example imports from rig. Since the example is written using the public rig crate path, the install command should install rig instead.
Problem
The quickstart currently shows:
But the example uses:
use rig::client::{CompletionClient, ProviderClient};
use rig::completion::Prompt;
use rig::providers::openai;
This can confuse new users because installing rig-core directly would require importing from rig_core, while the documented example imports from rig.
The example also uses:
#[tokio::main]
async fn main() -> Result<(), anyhow::Error>
So the setup should include Tokio with the required runtime features and the anyhow dependency.
Changes
Updated the install command from:
to:
cargo add rig anyhow dotenvy
cargo add tokio --features macros,rt-multi-thread
This keeps the example imports unchanged:
use rig::client::{CompletionClient, ProviderClient};
use rig::completion::Prompt;
use rig::providers::openai;
Also added:
before creating the OpenAI client, so users can load OPENAI_API_KEY from a local .env file during development.
Why
This makes the quickstart easier to follow and copy-paste for new users.
With the updated install command, users get:
rig for the documented import path
tokio with the async runtime features required for #[tokio::main]
anyhow for the example error type
dotenvy to load OPENAI_API_KEY from a local .env file during development
dotenvy is useful because many users prefer to store API keys in a .env file instead of exporting them manually in the terminal. This lets the quickstart work with:
OPENAI_API_KEY=your-api-key
Then the example can load it with:
Summary
This PR fixes the Rig quickstart setup so the install command matches the imports used in the example.
The docs currently install
rig-core, but the example imports fromrig. Since the example is written using the publicrigcrate path, the install command should installriginstead.Problem
The quickstart currently shows:
But the example uses:
use rig::client::{CompletionClient, ProviderClient}; use rig::completion::Prompt; use rig::providers::openai;This can confuse new users because installing
rig-coredirectly would require importing fromrig_core, while the documented example imports fromrig.The example also uses:
So the setup should include Tokio with the required runtime features and the anyhow dependency.
Changes
Updated the install command from:
to:
This keeps the example imports unchanged:
use rig::client::{CompletionClient, ProviderClient}; use rig::completion::Prompt; use rig::providers::openai;Also added:
dotenvy::dotenv().ok();before creating the OpenAI client, so users can load OPENAI_API_KEY from a local .env file during development.
Why
This makes the quickstart easier to follow and copy-paste for new users.
With the updated install command, users get:
rigfor the documented import pathtokiowith the async runtime features required for#[tokio::main]anyhowfor the example error typedotenvyto loadOPENAI_API_KEYfrom a local.envfile during developmentdotenvyis useful because many users prefer to store API keys in a.envfile instead of exporting them manually in the terminal. This lets the quickstart work with:Then the example can load it with:
dotenvy::dotenv().ok();