LLM chat
Ask Anthropic, OpenAI or Gemini with your own vault key through the completion endpoint; text or JSON out.
- AI
- Since 0.2.0
- ai
- llm
- chat
- claude
- openai
- gemini
- prompt
- json
- data
LLM chat sends a prompt to a language model with your own API key and sends the answer into the Patch as text or JSON.
What it does#
With trigger cabled, each trigger asks once; otherwise a new prompt does. The request goes to the Tune.Toys completion endpoint (POST /v1/ai/complete), which reads your key from the vault slot named after the provider (anthropic, openai or gemini) and calls the provider on the server. The key never reaches the browser or the Toy, and the platform's own key is never used for this node. Usage is billed to your key and shown on usage as tokens, model and provider.
The node's system field (up to 8 KiB) sets the instructions. context adds either a list of { role, content } messages as conversation history or any JSON as extra context. With Format JSON the model is asked for one JSON value, which arrives parsed on json; text always carries the raw answer, and bytes carries a data: base64 payload if the answer contains one.
A Toy with LLM chat requires the network and the provider's vault slot; the Play surface shows a chip until both are ready. During replay the model is not asked again: the recorded answers are played back, so a take plays without a key.
When to use it#
Use it to generate material: a melody as JSON for Data to MIDI, words for a display, settings from a description. Collect inputs with Merge to give it context.
Ports#
| Port | Direction | Signal | Lanes |
|---|---|---|---|
prompt | Input | Data (json) | 1 |
trigger | Input | Data (trigger) | 1 |
context | Input | Data (json) | 1 |
text | Output | Data (string) | 1 |
json | Output | Data (json) | 1 |
bytes | Output | Data (bytes) | 1 |
usage | Output | Data (json) | 1 |
error | Output | Data (string) | 1 |
Parameters#
| Parameter | Label | Range | Default | Unit | Scale | Notes |
|---|---|---|---|---|---|---|
provider | Provider | 0 to 2 | 0 | linear | Model provider; its key comes from the vault slot of the same name. Choices: 0 Anthropic, 1 OpenAI, 2 Gemini. | |
format | Format | 0 to 1 | 0 | linear | Ask for plain text or a JSON value. Choices: 0 Text, 1 JSON. | |
max_tokens | Max tokens | 1 to 8192 | 1024 | linear | Longest response in tokens. | |
temperature | Temperature | 0 to 2 | 1 | linear | Higher values make answers more varied. |
model: text.system: text.
Provider (provider)#
Anthropic, OpenAI or Gemini. Its key comes from the vault slot of the same name. The node's model field picks a model; it defaults to the first model the addon manifest pins and accepts any other model id.
Format (format)#
Text, or JSON to ask for a single JSON value on json.
Max tokens (max_tokens)#
The longest answer, 1 to 8 192 tokens. Longer answers cost more.
Temperature (temperature)#
0 to 2. Low values give steadier answers; higher values more varied ones.
Tips#
- Ask for exactly the JSON shape you want, and test it with a Console log on
textanderror. - Record a take of a good answer: it replays anywhere without a key.
See also#
Data to MIDI, Merge, Secrets and the vault, Data cables.
Help patches
Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.
1. Ask for a haiku
beginner Teaches: provider, format, max_tokens, temperature
A prompt goes to a language model with your own vault key; the answer is logged.
Connections as text
- Value value output connected to Convert value input
- LLM chat text output connected to Console log “log” value input
- LLM chat error output connected to Console log “oops” value input
- Convert value output connected to LLM chat prompt input
- Provider Anthropic uses the vault slot anthropic; the Toy only names the provider.
- Format Text; JSON asks for one JSON value on the json output.
Related nodes
- Data to MIDI Play a JSON list of notes in beats as MIDI on each trigger, scheduled on the transport.
- Merge Combine up to eight inputs into one JSON object keyed by port, when any or all have arrived.
- Console log Write each incoming value to the Console panel with a level and label, rate-limited.