Skip to main content

Klava is a CLI tool for using code agents with any provider. Use Claude Code with your OpenAI-compatible provider. Make code agents more secure by filtering out leaked secret keys and cryptographic keys from your filesystem.

Project description

klava

README file written by hands primarily

Klava is a CLI tool for using code agents with any provider. Use Claude Code with your OpenAI-compatible provider. Make code agents more secure by filtering out leaked secret keys and cryptographic keys from your filesystem.

Features

  • Fast & Lightweight: Written in Rust with async I/O
  • Universal: Works with any OpenAI-compatible API (OpenRouter, Qwen, Cloud.ru, local LLMs)
  • Security Guardrails: Filters out leaked secret keys and cryptographic keys from your filesystem before sending requests to LLM APIs

Installation

You can install klava from pip, cargo, mise!

pip install klava
cargo install klava --locked
mise use -g cargo:klava

Or you can build klava from source. You need to install rustup, clone the repository and then

cargo install --path . --locked

Launch AI Code Agent

The launch command starts the proxy server and launches an AI code agent with appropriate environment variables:

klava launch
klava launch claude
klava launch claude --provider qwen
klava launch opencode

Notice: When launching opencode, you need to manually select the "klava" model using the model command in opencode after it starts.

Supported code agents:

Agent Description Link
claude Claude Code https://code.claude.com
opencode OpenCode Agent https://opencode.ai/

Configuration File Location

To find the config file path on your system, run:

klava config

Platform-specific config file locations:

  • Linux: ~/.config/klava/config.toml
  • macOS: ~/Library/Application Support/klava/config.toml
  • Windows: %APPDATA%\klava\config.toml

Config file

port = 48017
verbose = false
active_provider = "qwen"

[[providers]]
name = "qwen"
type = "qwen-code"

[[providers]]
name = "cloudru"
type = "openai-compatible"
base_url = "https://foundation-models.api.cloud.ru"
api_key_name = "CLOUD_RU_KEY"
reasoning_model = "zai-org/GLM-4.7"
completion_model = "zai-org/GLM-4.7"

[[providers]]
name = "openrouter"
type = "openai-compatible"
base_url = "https://openrouter.ai/api"
api_key_name = "OPENROUTER_API_KEY"
reasoning_model = "z-ai/glm-5.1"
completion_model = "z-ai/glm-5.1"

Notice: base_url should not include /v1 at the end!

Notice: You can use api_key_name if you have the api_key in your environment, if you want you can set api_key in the toml file with the api_key variable.

Notice: The type can be openai-compatible or qwen-code. qwen-code uses an authentication flow involving reverse engineering of the Qwen Code application. You can use 1000 free requests per day of the great large model, but with risks due to this being an unofficial implementation of qwen-code.

Manual Claude Execution

If you run klava up, and you want to run claude manually use this command

ANTHROPIC_BASE_URL=http://localhost:48017 claude

Don't forget to change the port to your klava proxy server port.

View Proxy Logs

View or follow proxy server logs:

klava logs          # View recent logs
klava logs -f       # Follow logs (like tail -f)
klava logs --follow # Follow logs (long form)

Note: The -v flag works only with the klava up command to enable verbose logging. When used with klava logs, it doesn't change the output. To see verbose logs, start the server with klava up -v first, then view the logs.

Known Limitations

The following Anthropic API features are not supported currently (Claude Code and similar tools work without these parameters): Many features like images are not ready yet... It's a work-in-progress tool.

Troubleshooting & Known Pitfalls

  • ❌ Wrong: https://openrouter.ai/api/v1
  • ✅ Correct: https://openrouter.ai/api
  • The proxy automatically adds /v1/chat/completions

Roadmap & Contributing

Contributions welcome!

Current vision is:

  • Refactoring -> split codebase into many crates like proxy, cli, providers ...)
  • Add more Guardrails
  • Add Token optimization algorithms. Reduce cost is a crucial goal
  • Creating extensions mechanism as first class citizen.
  • Add more providers and agents
  • Add benchmark wars between agents
  • Add remote hand control using Telegram and Mobile

If you like it you can support me:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

klava-0.2.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

klava-0.2.3-py3-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

klava-0.2.3-py3-none-macosx_10_12_x86_64.whl (3.3 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file klava-0.2.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for klava-0.2.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e19a79bdb8a061fbc2c5412fc032ce7cae251e884dca768b2fd0308a8a4eafb
MD5 ae88c8c0ae1caaa9d05606e26c1e9158
BLAKE2b-256 8219debb431ddad8da98931dd6387204d35c93c66b3f0a49e6a6fa440791f75d

See more details on using hashes here.

File details

Details for the file klava-0.2.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klava-0.2.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05bd6a256959e8a03f49063ceeccb9a2dccca571178992c65609c32d2ae9dc5f
MD5 d9a4714eb3ce07522b8160e7197ef4f3
BLAKE2b-256 97025ecf97165591019e319831a965518fc13f49f9988e754c40b4acdfe0f6b8

See more details on using hashes here.

File details

Details for the file klava-0.2.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for klava-0.2.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6fb95f038aa6594b297f3fc9d18a5039c6eeab4dc07e4efd0f7577dfc174c72a
MD5 4f1ba686c9c98045a331d2c923e15c47
BLAKE2b-256 d2f3120b568f337748d9df216c2231ea235edeb29fb33e9e9edd46a133337c4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page