Quickstart
Open your first run from TypeScript, at the console, or from the command line.
Install the SDK
npm install @curta/sdk@curta/sdk is a TypeScript package for Node 20 and later and for the browser. It carries the client and the WebAssembly build of curta-core, the same inference core the program runs.
The one line
import { Connection, PublicKey } from '@solana/web3.js'
import { Curta } from '@curta/sdk'
const curta = new Curta({ connection: new Connection(rpcUrl), wallet })
const model = new PublicKey(modelAddress)
const { text, address } = await curta.run({ model, prompt })wallet is a keypair, or any object with a publicKey and signTransaction. The constructor also takes programId.
The call also takes three parameters:
| Parameter | Type | Default |
|---|---|---|
| maxTokens | number, from 1 to the model’s context length | 32 |
| temperature | number, from 0 to 16 | 0 |
| seed | bigint, 64 bits | 1n |
model is the address of a sealed model from the registry. prompt is the text the model continues.
The call opens a run, deposits its budget and the run account’s rent in SOL from your wallet, waits while crankers land turns, and resolves when the run is complete. It takes onTurn, a callback that receives the run as it advances, and signal, an AbortSignal that ends the wait. Runs and turns describes what happens on chain in between.
What comes back
- The text: the model’s output, read from the run account.
- The run address: the account that holds the prompt, the output and every parameter of the run.
- The tokens: the ids of the tokens the model produced.
Open /runs/[address] with that address to read the run on the site: each turn with its signature, cranker and compute units, and the text as the chain holds it.
The other SDK calls
| Call | What it does |
|---|---|
| run | Opens a run, waits while crankers turn it and returns the text, the run address and the token ids. |
| openRun | Opens a run and returns its address, the signature and the quote once the opening transaction lands. |
| turn | Lands one turn on a run, signed and paid for by your wallet, which receives the turn reward. |
| quote | Computes the turns, the budget and the run account’s size and rent for a model, a prompt and parameters. |
| getRun | Reads a run account: state, parameters, budget, turns, prompt, token ids and text. |
| getModel | Reads a model: publisher, configuration, royalty, weights hash, sealed flag and weight accounts. |
| replay | Recomputes a run from the on-chain weights and compares it token by token. |
Each of the seven is a method on the client and a named export that takes the client first. Amounts are bigints in lamports. The client also has fund, cancel, settle and close for a run, publish, seal, setRoyalty and claim for a model, and getConfig, getRunHead and getWeights for reads. Run a cranker covers the crank export and Program reference the instruction builders and decoders.
The same run at the console
- Open /run and press Connect wallet.
- Choose a sealed model and type a prompt. Set max tokens, temperature and seed.
- Read the quote: the turns the run takes and its budget in SOL. Fees explains each line.
- Press Open run and sign. One transaction creates the run account and deposits the budget.
- Watch turns land. Tokens and text appear from the run account as they complete.
- When the run is complete, press Settle, then Close run.
The same run with the CLI
curta run <model> <prompt> --max-tokens 32 --temperature 0 --seed 1The command opens a run, lands every turn itself with the same wallet, and prints one JSON object when the run is complete: the run address, the text, the token ids and the count of turns. The three flags are shown with their defaults.
curta is the bin of the @curta/cli package, for Node 20 and later. Every command that reaches the chain takes these flags, or the environment variable beside each:
| Flag | Environment variable | Value |
|---|---|---|
| --rpc | CURTA_RPC_URL | The RPC endpoint. |
| --keypair | CURTA_KEYPAIR | The path of the keypair file that signs and pays. |
| --program-id | CURTA_PROGRAM_ID | The address of the curta program. |
curta help prints every command with its flags.