#claude #server #model #default #client #config #endpoint

bin+lib toast-api

An unofficial CLI client and API server for Claude

1 unstable release

new 0.1.1 May 19, 2025

#23 in #claude

MIT and GPL-3.0 licenses

57KB
1K SLoC

Toast - Claude CLI & API Server

An unofficial CLI client and API server for Claude that provides both a command-line interface and OpenAI-compatible API endpoints.

Overview

Toast provides two interfaces for working with Claude:

  1. A CLI client for direct interaction with Claude (default)
  2. An API server that provides OpenAI-compatible endpoints for use with clients and libraries

Features

  • Interactive CLI interface with Claude
  • OpenAI-compatible API server
  • Conversation state management
  • Model mapping (gpt-4/gpt-4.1 → Claude models)
  • CORS support for browser clients

Installation

# Clone the repository
git clone https://github.com/yourusername/toast.git
cd toast

# Build the project
cargo build --release

Usage

CLI Mode (Default)

By default, Toast runs in CLI mode, providing an interactive command-line interface to Claude:

./target/release/toast

CLI options:

# Use Claude Opus model
./target/release/toast --opus

# Use Claude Haiku model
./target/release/toast --haiku

# Use a custom model
./target/release/toast --custom-model claude-3-5-sonnet-20240620

CLI Commands

While in the CLI interface:

  • Enter your message and press Enter to send to Claude
  • Use /exit or exit or x to quit
  • Use # exec <command> to execute shell commands
  • Use # read_file <filename> to read files and send them to Claude

API Server Mode

To run in server mode, use the --serve or -s flag:

# Start the API server
./target/release/toast --serve

# Custom port
./target/release/toast --serve --port 8080

# Custom model
./target/release/toast --serve --model claude-3-opus-20240229

# Custom host address
./target/release/toast --serve --host 127.0.0.1

API Endpoint

The server exposes the following OpenAI-compatible endpoints:

  • POST /v1/chat/completions - Chat completions API

API Reference

Chat Completions

POST /v1/chat/completions

Request body:

{
  "model": "gpt-4.1",
  "messages": [
    {
      "role": "developer",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}

Response:

{
  "id": "f52a7702-6588-4b68-a057-bc2630d223b8",
  "object": "chat.completion",
  "created": 1683989000,
  "model": "claude-3-opus-20240229",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Claude, a helpful AI assistant. How can I assist you today?"
      }
    }
  ]
}

Model Mapping

The server maps OpenAI model names to Claude models:

  • gpt-3.5-turbo → Claude Haiku
  • gpt-4, gpt-4-turbo → Claude Sonnet
  • gpt-4o, gpt-4.1 → Claude Opus

You can also specify a Claude model directly in the model field.

Authentication

Authentication is disabled by default. The server ignores any API keys provided in requests.

Configuration

Toast requires Claude authentication credentials stored in the config directory:

  • MacOS: ~/Library/Application Support/toast/
  • Linux: ~/.config/toast/
  • Windows: C:\Users\{USERNAME}\AppData\Roaming\toast\

Required files:

  • cookie: Contains the Claude cookie value
  • org_id: Contains your Claude organization ID (extracted automatically from cookie if not present)

Development

Building from source

cargo build

Running tests

cargo test

License

MIT

Dependencies

~59MB
~1.5M SLoC