Skip to content

docs: fix quickstart rig-core imports #88

Description

@Parikalp-Bhardwaj

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:

cargo add rig-core tokio

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:

cargo add rig-core tokio

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:

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:

  • 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:

dotenvy::dotenv().ok();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions