Inklings Library
A unified Rust API for various Large Language Model (LLM) providers. Currently supports OpenAI and Anthropic APIs with a consistent interface. Support is planned for all common LLM providers.
The goal of this library is to make it as easy as possible to use multiple different LLM providers while being very easy get started with. It is supposed to be easy to use on all platforms and with all common programming languages. For this reason there will be thin language bindings for both Python and JavaScript to make
Features
- Unified interface for multiple LLM providers
- Async/await based API
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
The library provides two main ways to interact with LLMs: simple completions and chat-based interactions.
Simple Completion
Use complete() for quick, single-prompt interactions:
use ;
async
Chat Interface
Use chat() when you need more control over the conversation flow, including system prompts and message history:
use ;
async
The chat interface gives you more flexibility by allowing you to:
- Set system-level instructions
- Maintain conversation context
- Control the role of each message (System, User, or Assistant)
CLI Example
The repository includes a simple CLI example demonstrating the library usage:
# Set your API keys
# Run with a custom prompt
This will query all available LLM providers and show their responses.
Streaming Interface
use StreamExt;
use ;
async
Supported Providers
OpenAI
- Default model: gpt-4o-mini
- Requires OPENAI_API_KEY environment variable
Anthropic
- Default model: claude-3-5-haiku-20241022
- Requires ANTHROPIC_API_KEY environment variable
Mock Provider
- Useful for testing
- Can be configured to return specific responses or errors
Usage Examples
Chat Interface
use ;
async
Using Different Providers
// OpenAI
let openai = new;
// Anthropic
let anthropic = new;
// Mock (for testing)
let mock = new;
Testing
The library includes several types of tests:
Unit Tests
Run with:
Integration Tests with Real APIs
These tests are marked with #[ignore] and require API keys:
# Run ignored tests (requires API keys)
# Run all tests including ignored ones
Mock Testing
The MockProvider allows testing without real API calls:
let provider = new;
// or
let provider = with_error;