Getting started

Quickstart

Send your first completion in about five minutes. If you've used the OpenAI API before, you already know the moves — point the client somewhere new and go.

Five minutes to a completion

  1. 1
    Create an account

    Sign in with email or wallet via Privy. A credit balance is created for you automatically — new accounts get a small amount to try things out.

  2. 2
    Get an API key

    Open Settings → Keysand create a key. It's shown once — store it as PIEDPIPER_API_KEY. Keys look like sk-pied-piper-… and can be revoked any time.

  3. 3
    Point your client at Pied Piper

    Use the official @piedpiperrh/sdk, or any OpenAI-compatible client with baseURL set to https://mesh-zeta-eight.vercel.app/v1.

  4. 4
    Send a request

    Pick a model slug from the catalog and callchat.completions.create. Pied Piper routes it to a live host and streams the result back.

Python

python
1from openai import OpenAI
2
3client = OpenAI(
4 api_key=os.environ["PIEDPIPER_API_KEY"],
5 base_url="https://mesh-zeta-eight.vercel.app/v1",
6)
7
8r = client.chat.completions.create(
9 model="llama-3.2-3b-instruct-q4f32_1",
10 messages=[{"role": "user", "content": "Explain Pied Piper in one line."}],
11)
12print(r.choices[0].message.content)

TypeScript

typescript
1import OpenAI from "openai";
2
3const client = new OpenAI({
4 apiKey: process.env.PIEDPIPER_API_KEY,
5 baseURL: "https://mesh-zeta-eight.vercel.app/v1",
6});
7
8const r = await client.chat.completions.create({
9 model: "llama-3.2-3b-instruct-q4f32_1",
10 messages: [{ role: "user", content: "Explain Pied Piper in one line." }],
11});
12console.log(r.choices[0].message.content);

Streaming

Set stream: true to receive server-sent events as tokens are produced — the same SSE format OpenAI uses, terminated by data: [DONE].

typescript
1const stream = await client.chat.completions.create({
2 model: "llama-3.2-3b-instruct-q4f32_1",
3 messages: [{ role: "user", content: "Count to five." }],
4 stream: true,
5});
6
7for await (const chunk of stream) {
8 process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
9}
First request may wait
If a host advertises a model but hasn't loaded it yet, Pied Piper holds your request while the host warms up (up to ~60s) instead of failing. Warm models respond immediately. See Models.

Where to go next

Read the full API reference for every parameter and header, learn the core concepts behind dispatch and credits, or start hosting to earn while you sleep.