Skip to content

Groq, OpenRouter & others

Every other provider is one prefix away. They all use the openai SDK (pip install "dyui[openai]") against the provider’s OpenAI-compatible endpoint, so switching is a change of model string and key. The full table of prefixes, endpoints, key variables and base-URL overrides is on Models & providers, and where to get each key is on API keys & environment.

The model id may itself contain slashes. Inside your handler, any of these works:

dyui.llm.stream("nvidia/moonshotai/kimi-k2.6", chat.history, components=app.catalog)
dyui.llm.stream("openrouter/anthropic/claude-sonnet-5-5", chat.history, components=app.catalog)
dyui.llm.stream("together/meta-llama/Llama-3.3-70B-Instruct-Turbo", chat.history, components=app.catalog)
dyui.llm.stream("groq/llama-3.3-70b-versatile", chat.history, components=app.catalog)
dyui.llm.stream("gemini/gemini-2.5-flash", chat.history, components=app.catalog)

base_url= and api_key= arguments override the environment. A provider DyUI doesn’t list still works if it speaks the OpenAI API: use openai/<model> with base_url=, or bring your own SDK.

Free tiers (Groq, NVIDIA NIM, Gemini) limit tokens per minute. Keep the catalog and history short; see rate limits and free tiers.

One app for every provider: pick it with DYUI_MODEL. It trims the catalog and the history so requests stay inside free-tier limits.

app.py
"""One app, any provider: pick it with DYUI_MODEL.
Needs: pip install "dyui[openai]" and the key for your provider in a .env file next to this one,
e.g. GROQ_API_KEY for groq/..., OPENROUTER_API_KEY for openrouter/..., GEMINI_API_KEY for gemini/...
Save as app.py, then run: dyui run app.py
"""
import os
import dyui
MODEL = os.getenv("DYUI_MODEL", "groq/llama-3.3-70b-versatile")
app = dyui.App(title="Any Model", description=f"Answering with {MODEL}.", starters=["Show a bar chart of planet sizes"])
# Free tiers limit tokens per minute: a short catalog keeps every request small.
CATALOG = app.catalog.only("table", "stats", "stat", "chart", "callout", "quick_replies")
@app.on_message
async def reply(msg: dyui.Message, chat: dyui.Chat):
async for part in dyui.llm.stream(
MODEL,
chat.history[-12:], # cap the history you resend
system="You are a concise assistant.",
components=CATALOG,
):
yield part
  1. Save it as app.py in a new, empty file, or download app.py.

  2. Put the provider’s key and, if you like, the model in a .env file next to it:

    .env
    GROQ_API_KEY=gsk_...
    # DYUI_MODEL=openrouter/anthropic/claude-sonnet-5-5 (with OPENROUTER_API_KEY)
  3. Run it:

    Terminal window
    pip install "dyui[openai]"
    dyui run app.py
  4. Open http://localhost:8000 and send the starter.

DyUI Docs assistant

Answers come from the DyUI docs. gpt-oss-120b via Groq. Press Escape or the close button to return to the page.