# How to use Rig with Subconscious

> To use Rig with Subconscious, build an `openai::CompletionsClient` with `.base_url("https://api.subconscious.dev/v1")` and your API key, then create an agent with `client.agent("subconscious/glm-5.3-marathon")`. Rig then calls Subconscious through Chat Completions, billed per token.

Canonical page: https://www.subconscious.dev/agents/frameworks/rig
Category: [Frameworks](https://www.subconscious.dev/agents/frameworks)
Last verified: 2026-09-30
Rig: https://rig.rs
Source: https://github.com/0xPlaygrounds/rig

## Before you start

- Rust and Cargo
- A Subconscious account and API key

## Set up Rig

### 1. Install Rig

Install the framework and its OpenAI-compatible client.

```bash
cargo add rig@0.42 anyhow
cargo add tokio --features macros,rt-multi-thread
```

### 2. Create a Subconscious API key

Sign in at https://platform.subconscious.dev, create an API key, and export it so the tool can read it.

```bash
export SUBCONSCIOUS_API_KEY="your_key"
```

### 3. Point it at Subconscious

Written for Rig 0.42. openai::Client targets OpenAI's Responses API, so use CompletionsClient for Chat Completions. The base URL keeps /v1.

```rust
use rig::prelude::*;
use rig::providers::openai;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let client = openai::CompletionsClient::builder()
        .api_key(std::env::var("SUBCONSCIOUS_API_KEY")?)
        .base_url("https://api.subconscious.dev/v1")
        .build()?;

    let agent = client
        .agent("subconscious/glm-5.3-marathon")
        .preamble("You are a helpful assistant.")
        .build();

    let response = agent.prompt("Hello!").await?;
    println!("{response}");
    Ok(())
}
```

### 4. Run it

Build and run.

```bash
cargo run
```

## Connection details

- OpenAI-compatible base URL: https://api.subconscious.dev/v1
- Anthropic-compatible base URL: https://api.subconscious.dev
- API key: From subc login or the Subconscious dashboard
- Model: subconscious/glm-5.3-marathon
- Multimodal, high-throughput model: subconscious/deepseek-v4.1-flash-marathon

Full API reference: https://docs.subconscious.dev

## Frequently asked questions

### Which Subconscious model should I use with Rig?

Start with subconscious/glm-5.3-marathon, an open frontier coding model built for long agent runs. subconscious/deepseek-v4.1-flash-marathon is a cheaper, high-throughput alternative that also takes image input. Use the full model ID, including the subconscious/ prefix.

### Is Rig on Subconscious OpenAI- or Anthropic-compatible?

This guide connects Rig through the OpenAI-compatible Subconscious API. Subconscious serves both formats: OpenAI Chat Completions at https://api.subconscious.dev/v1 and Anthropic Messages at https://api.subconscious.dev.

### How is Rig usage on Subconscious billed?

Per token by default, with no commitment. Heavy users can switch to a monthly token plan: a fixed price for a large daily token allowance shared across your team.
