Skip to main content

Streamlit connection for OrcaRouter — adaptive LLM routing across 150+ models through one OpenAI-compatible API

Project description

st-orcarouter

A Streamlit connection for OrcaRouter — an OpenAI-compatible LLM gateway with adaptive routing across 150+ models behind a single API key.

st-orcarouter plugs OrcaRouter into Streamlit's st.connection mechanism, so you get cached completions, token-by-token streaming for st.write_stream, and a model list for st.selectbox without writing the client wiring yourself.

I'm an engineer on the OrcaRouter team.

Install

pip install st-orcarouter

Quickstart

  1. Get an API key at https://www.orcarouter.ai/console.

  2. Add it to .streamlit/secrets.toml:

    [connections.orcarouter]
    api_key = "sk-orca-xxxx"
    
  3. Use it in your app:

    import streamlit as st
    from st_orcarouter import OrcaRouterConnection
    
    conn = st.connection("orcarouter", type=OrcaRouterConnection)
    
    # One-shot, cached completion
    st.write(conn.chat("Tell me a joke", ttl=3600))
    
    # Streaming straight into the chat UI
    st.write_stream(conn.stream("Write a short story"))
    
    # Populate a model picker with the models your key can use
    model = st.selectbox("Model", conn.list_models())
    
  4. Run it:

    streamlit run your_app.py
    

A complete chatbot is in examples/streamlit_app.py.

API

st.connection("name", type=OrcaRouterConnection) returns an OrcaRouterConnection with:

Member Description
chat(messages, *, model="orcarouter/auto", ttl=None, **params) -> str Non-streaming completion, cached with st.cache_data. messages may be a prompt string or a list of chat messages.
stream(messages, *, model="orcarouter/auto", **params) -> Iterator[str] Streaming completion that yields content deltas; pass it to st.write_stream.
list_models(*, ttl=3600, chat_only=True) -> list[str] Model ids your key can use (via GET /v1/models), cached. chat_only filters out image / audio / embedding models.
client The underlying authenticated openai.OpenAI client for anything not wrapped here (embeddings, tool calls, etc.).

Extra keyword arguments (temperature, reasoning_effort, extra_body, ...) are forwarded to the OpenAI chat-completions call unchanged.

Models and routing

Configuration

The API key is resolved in this order:

  1. st.connection(..., api_key="sk-orca-...")
  2. the [connections.<name>] section of .streamlit/secrets.toml
  3. the ORCAROUTER_API_KEY environment variable

You can override the base URL with base_url= or a base_url secret (defaults to https://api.orcarouter.ai/v1).

Development

pip install -e ".[dev]"
pytest                              # offline unit tests, no API key needed
python scripts/orcarouter-live-test.py   # live end-to-end check (needs a real key)

License

Apache-2.0.

Project details


Download files

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

Source Distribution

st_orcarouter-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

st_orcarouter-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file st_orcarouter-0.1.0.tar.gz.

File metadata

  • Download URL: st_orcarouter-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for st_orcarouter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1dff859b665f7c2eb9a1548116fcda9cf20d19935e5528d43d8a9d486bf58f4
MD5 abed1371c9eb83e452a92527719767b6
BLAKE2b-256 b8d37c5e4147c1b326627472a8004d80d643b5fb7299b50e2c934f7ae578f379

See more details on using hashes here.

File details

Details for the file st_orcarouter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: st_orcarouter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for st_orcarouter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7d5367b7c4e26da4f4c63400bea6085abeec2782a4eff1d6971c82524d11cc9
MD5 7b1524a3176a9e7269d7288e304262c8
BLAKE2b-256 b254a9b336651d25ab94dea557aaf74185b4f12d2d239531685fa0083ecbd1a8

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