Minimal universal LLM interface API
Project description
Toki
A minimal python library for talking to LLMs.
When using this library, in most cases one can simply switch the model name (e.g. 'openai/gpt-5' -> 'google/gemini-2.5-pro') and everything will just work.
Getting Started
pip install toki
from toki import Model, Agent, get_openrouter_api_key
from easyrepl import REPL
agent = Agent(
Model('openai/gpt-5', get_openrouter_api_key())
)
for query in REPL():
agent.add_user_message(query)
for chunk in agent.execute(stream=True):
print(chunk, end='', flush=True)
print()
Features
Model: stateless class for talking to LLMs. includes blocking and streamingAgent: class for maintaining conversation history when talking with a modelStateMachine/ClassStateMachine: tools for easily implementing complex agentic interaction scenarios
Backends
The primary backend is OpenRouter which provides REST API access to all major LLM models on the market
Issues
OpenAI models fail to work with tools
- TODO: consider adding a separate backend just for openai. also consider adding a text only tools interface to skip around the issue
Dev
Rebuild models list file
toki-fetch-models
- TODO: look into making this step part of the github action for publishing new version (or periodically checking the models list and auto updating/building new versions)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toki-0.2.4.tar.gz.
File metadata
- Download URL: toki-0.2.4.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f189210fb3c581558414523be7da6d29da2515c4011510e6420c6264faa895bf
|
|
| MD5 |
0b09f6c7e1cd95fda75a530d6c79ed5d
|
|
| BLAKE2b-256 |
9c43947133155d86cf4c223205caec203850c2d7452bcdea1815052cdfc70923
|
File details
Details for the file toki-0.2.4-py3-none-any.whl.
File metadata
- Download URL: toki-0.2.4-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aafe58eeca0368e76534b2e589a087473ebe80e7f0f3c4712559baa8c1227b1e
|
|
| MD5 |
e25700a743e7c48acb63b58a664c8e70
|
|
| BLAKE2b-256 |
aa26acec728c38106d6188029607776c903749489e8ce943a9d250660c4e7a9c
|