Light Logo

Quickstart

This quickstart will walk you through running your first model with WriftAI

Create an Access Token

WriftAI uses access tokens to authenticate API calls and CLI commands.

  1. Open the Access Tokens page in your dashboard
  2. Create a new token and copy it somewhere safe — you’ll need it in the next step.

Set Your Access Token

Export your access token as an environment variable:

export WRIFTAI_ACCESS_TOKEN="YOUR_TOKEN_HERE"

Run a Model in the Cloud

WriftAI can execute models in the cloud with no local setup required. Cloud runtimes automatically scale based on demand, making it ideal for production workloads or environments without GPUs.

To run hexgrad/kokoro-82m in the cloud:

First, install the wriftai python library

pip install wriftai

Then make a request

from wriftai import Client

# Instantiate the WriftAI client
wriftai = Client()

# Create a prediction using hexgrad/kokoro-82m and wait for it to complete
prediction = wriftai.predictions.create(
    model="hexgrad/kokoro-82m",
    input={
        "text": "Good morning! Here is your daily summary.",
    },
    wait=True,
)

print(prediction.output)
# https://cdn.wrift.ai/temporary/audio-6808ef49.wav

First, install the wriftai library

npm install wriftai

Then make a request

import { WriftAI } from 'wriftai';

// Instantiate the WriftAI client
const wriftai = new WriftAI();

// Create a prediction using hexgrad/kokoro-82m and wait for it to complete
const prediction = await wriftai.predictions.create(
  {
    model: 'hexgrad/kokoro-82m',
    input: {
      text: 'Good morning! Here is your daily summary.',
    },
  },
  true, // wait for completion
);

console.log(prediction.output);
// https://cdn.wrift.ai/temporary/audio-6808ef49.wav

First install the package

go get -u github.com/wriftai/wriftai-go

Then make a request

import (
	"context"
	"encoding/json"
	"fmt"
	"log"

	"github.com/wriftai/wriftai-go"
)

func main() {
	// Instantiate the WriftAI client
	client := wriftai.NewClient()

	// Create a prediction using hexgrad/kokoro-82m and wait for it to complete
	prediction, err := client.Predictions.Create(
		context.TODO(),
		wriftai.CreatePredictionParams{
			Model: "hexgrad/kokoro-82m",
			Input: wriftai.PredictionInput{
				"text": "Good morning! Here is your daily summary.",
			},
		},
		true, // wait for completion
		nil,  // use default wait options
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Print(prediction.Output)
	// https://cdn.wrift.ai/temporary/audio-6808ef49.wav
}

Install the WriftAI CLI, if you haven't, and make a request

# Create a prediction using hexgrad/kokoro-82m and wait for it to complete
wriftai predictions create \
   --model hexgrad/kokoro-82m \
   --input 'text=Good morning! Here is your daily summary.' \
   --wait
# Create a prediction and prefer to wait on the server. If the server
# wait is exceeded, fallback to short polling
response=$(
  curl "https://api.wrift.ai/v1/predictions" \
    -H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Prefer: wait" \
    -d '{
      "model": "hexgrad/kokoro-82m",
      "input": {
        "text": "Good morning! Here is your daily summary."
      }
    }'
)

# Extract prediction ID and status from the initial response
prediction_id=$(echo "$response" | jq -r '.id')
status=$(echo "$response" | jq -r '.status')
poll_response="$response"

# Poll until status is terminal
while [[ "$status" != "succeeded" \
      && "$status" != "failed" \
      && "$status" != "cancelled" \
      && "$status" != "abandoned" ]]; do
  sleep 1
  poll_response=$(
    curl "https://api.wrift.ai/v1/predictions/$prediction_id" \
      -H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN"
  )
  status=$(echo "$poll_response" | jq -r '.status')
done

# Print the output
echo "$poll_response" | jq -r '.output'
# https://cdn.wrift.ai/temporary/audio-6808ef49.wav

Run a Model Locally

You can run models directly on your machine using the WriftAI CLI.

To run hexgrad/kokoro-82m locally:

wriftai model start hexgrad/kokoro-82m

This command downloads the model and starts serving it on http://localhost:8000.

Then, set the base URL to point to your local server:

export WRIFTAI_API_BASE_URL=http://localhost:8000

Once the server is running, use the same SDKs, CLI commands, and API calls shown above — they'll automatically route requests to your local server.