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:

ParameterTypeDefault
maxTokensnumber, from 1 to the model’s context length32
temperaturenumber, from 0 to 160
seedbigint, 64 bits1n

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

CallWhat it does
runOpens a run, waits while crankers turn it and returns the text, the run address and the token ids.
openRunOpens a run and returns its address, the signature and the quote once the opening transaction lands.
turnLands one turn on a run, signed and paid for by your wallet, which receives the turn reward.
quoteComputes the turns, the budget and the run account’s size and rent for a model, a prompt and parameters.
getRunReads a run account: state, parameters, budget, turns, prompt, token ids and text.
getModelReads a model: publisher, configuration, royalty, weights hash, sealed flag and weight accounts.
replayRecomputes 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

  1. Open /run and press Connect wallet.
  2. Choose a sealed model and type a prompt. Set max tokens, temperature and seed.
  3. Read the quote: the turns the run takes and its budget in SOL. Fees explains each line.
  4. Press Open run and sign. One transaction creates the run account and deposits the budget.
  5. Watch turns land. Tokens and text appear from the run account as they complete.
  6. 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 1

The 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:

FlagEnvironment variableValue
--rpcCURTA_RPC_URLThe RPC endpoint.
--keypairCURTA_KEYPAIRThe path of the keypair file that signs and pays.
--program-idCURTA_PROGRAM_IDThe address of the curta program.

curta help prints every command with its flags.