API Features

W.ai API Overview

Our decentralized network delivers affordable, on-demand AI inference compute through a simple OpenAI compatible HTTP API.

Need real credentials? The keys shown below are dummy examples (wsk-examplekey). To obtain production keys or discuss a partnership, email [email protected].


API Usage Guide

This guide provides instructions on how to interact with our various API endpoints using curl.

Authorization

Ensure you include your authorization header with your API key:

Authorization: Bearer wsk-examplekey

List Available Models

Retrieve metadata for available models:

curl -X GET 'https://api.w.ai/v1/models'

Model Examples:

  • llama-3.2-1b-4bit

  • llama-3.3-70b-4bit

  • flux-1-dev

  • flux-1-kontext-dev

  • sdxl

  • gemma-3-27b-4bit

Text-Only Chat (Llama, Mistral, Gemma, etc.)

Perform text-based interactions using LLM models like Llama:

curl -X POST 'https://api.w.ai/v1/chat/completions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer wsk-examplekey' \
  --data '{
    "model": "llama-3.2-1b-4bit",
    "messages": [
      { "role": "user", "content": "Hello! Who is davinci?" }
    ],
    "max_tokens": 150,
    "stream": false
  }'

Vision-Language Chat (Gemma-3-27B-4bit)

Describe the contents of images with VLM models like gemma-3:

curl -X POST 'https://api.w.ai/v1/chat/completions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer wsk-examplekey' \
  --data '{
    "model": "gemma-3-27b-4bit",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "image_url", "image_url": { "url": "http://images.cocodataset.org/val2017/000000039769.jpg" } },
          { "type": "text", "text": "Describe the contents of this image." }
        ]
      }
    ],
    "max_tokens": 150,
    "stream": false
  }'

Image Generation (Flux-1-dev, SDXL)

Generate images based on text prompts:

curl -X POST 'https://api.w.ai/v1/images/generations' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer wsk-examplekey' \
  --data '{
    "model": "flux-1-dev",
    "prompt": "A green photorealistic hand in the matrix holding a sign that says `W.ai`, everything should be binary 1s and 0s",
    "size": "512x512"
  }'

Image Editing (Flux-1-Kontext-dev)

Edit images using specified prompts:

curl -X POST 'https://api.w.ai/v1/images/edits' \
  --header 'Authorization: Bearer wsk-examplekey' \
  --header 'Content-Type: multipart/form-data' \
  --form 'model=flux-1-kontext-dev' \
  --form 'prompt=Convert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture' \
  --form image=@/path/to/cat.jpg \
  --form 'guidance_scale=2.5'

Ensure the file paths and prompts are customized to your needs.

Last updated