Polyglot

An API quickstart with language tabs. The values every language shares glide to their new places when you switch, you can edit them right in the code, and Run streams the response in underneath.

  • Code
  • Developer
  • AI

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
curl https://api.nova.ai/v1/responses \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "model": "",
    "input": "Write a haiku about latency"
  }'
Highlighted values are editable
Response

Press Run to send the request

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/polyglot.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/polyglot

Examples

Finished sections built with Polyglot. Each one installs whole, with the component included.

Three-Step Quickstart

Install, authenticate and a first request as three blocks sharing one `syncKey`. Switch any of them and all three change together; the package name slides from `pip install nova` into the Go import path. Your choice is remembered.

  1. 1

    Install the SDK

    One package, no native dependencies.

    pip install nova
  2. 2

    Authenticate

    Create a key in the dashboard. Hover it to check which one you're using.

    from nova import Nova
    
    client = Nova(api_key="")
  3. 3

    Make your first request

    Change the prompt or the model, then run it.

    reply = client.responses.create(
        model="",
        input="Say hello in five words",
    )
    print(reply.text)
    Highlighted values are editable

Send an Email

Not only for chat: an email API with the recipient and subject editable in the code. Run streams the JSON the API returns (`responseLang="json"`), and the recipient flies in as the request.

Sendwell API

Your first email is one request away.

Type a recipient and a subject right in the code, pick your language, and send. The response is the same in every one of them.

  • Queued in under 50 ms
  • Webhooks for every delivery
  • SDKs for 6 languages
curl https://api.sendwell.dev/v1/emails \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "from": "orders@acme.dev",
    "to": "ada@example.com",
    "subject": "Your order has shipped",
    "html": "<p>Thanks for your order!</p>"
  }'
Highlighted values are editable

Props

slotsRequired

TypeRecord<string, PolyglotSlot>

The values every snippet shares, keyed by the name used in {{name}}. Each has a value, and optionally editable (click and type), options (a small dropdown), secret (prefix and dots until hovered; Copy uses the real value) and label for screen readers.

snippetsRequired

TypePolyglotSnippet[]

One tab per language: { label, lang, code }. Write {{name}} wherever a slot's value goes; it's escaped for the quotes around it, so a typed " becomes \" in Python and stays valid inside a shell-quoted JSON body. lang picks the built-in highlighting: bash, python, js/ts, go, ruby or json.

response

Typestring | ((values) => string)

The reply Run streams, token by token. Passing it (or onRun) adds the Run footer and the response panel. Build it from the values to follow what the visitor typed.

onRun

Type(values, signal: AbortSignal) => AsyncIterable<string>

Call a real API instead: yield the reply in chunks. Stop, a new run or an edited value aborts signal.

speed

Typenumber | ((values) => number)Default60

Tokens per second for response, with a little jitter so it reads like a real stream.

latency

Typenumber | ((values) => number)Default350

Milliseconds before the first token of response. The status line counts it up.

syncKey

Typestring

Blocks with the same key switch language together and animate at once, matching tabs by label. The choice is remembered on this device.

defaultLabel

Typestring

The tab shown first, by label. Defaults to the first snippet.

lineNumbers

TypebooleanDefaultfalse

Show a line-number gutter. It stays put while the code scrolls sideways.

layout

Type"stack" | "split"Default"stack"

stack opens the response panel under the code on the first run. split puts it beside the code once the block is 48rem wide (a container query), waiting with an empty state, and stacks it below on narrower blocks.

echo

Typestring | false

The slot whose value flies into the response as its first line when you run. Defaults to the first editable slot; false turns it off.

responseLang

TypestringDefault"text"

Highlighting for the response, e.g. json.

statusText

TypestringDefault"200 OK"

Shown when a run finishes, before the time and the token count.

className

Typestring

Classes for the block, e.g. a max width. Colors come from the theme's foreground, muted and border; the highlighter's hues are one map at the top of the file.