← back

Developer docs

The CoralMesh API is OpenAI-compatible. If your code already speaks to api.openai.com, point it at https://api.coralmesh.io and you’re done.

1. Get an API key

Sign in, go to Account, and copy api_key. Pass it as a Bearer token — standard OpenAI conventions apply.

2. cURL

curl https://api.coralmesh.io/v1/chat/completions \
  -H "Authorization: Bearer cm_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen2.5:3b",
    "messages": [{"role":"user","content":"Hi from cURL"}]
  }'

3. Python (official OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.coralmesh.io/v1",
    api_key="cm_live_...",
)

stream = client.chat.completions.create(
    model="qwen2.5:3b",
    messages=[{"role": "user", "content": "ping"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

4. Node / TypeScript (official OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.coralmesh.io/v1",
  apiKey: process.env.CORALMESH_KEY,
});

const r = await client.chat.completions.create({
  model: "qwen2.5:3b",
  messages: [{ role: "user", content: "hi" }],
  stream: true,
});
for await (const part of r) {
  process.stdout.write(part.choices[0]?.delta?.content ?? "");
}

5. .NET / C# (community OpenAI client)

using OpenAI;

var client = new OpenAIClient(
    new OpenAIClientOptions {
        Endpoint = new Uri("https://api.coralmesh.io/v1")
    },
    "cm_live_..."
);
var resp = await client.GetChatClient("qwen2.5:3b")
    .CompleteChatAsync(new[] { new UserChatMessage("hi from .NET") });
Console.WriteLine(resp.Value.Content[0].Text);

Endpoints

  • POST /v1/chat/completions — OpenAI-compatible chat, with SSE streaming.
  • GET /v1/models — list of network-blessed models with their per-token price.
  • GET /v1/balance — your current credit balance, broken down by source.
  • GET /v1/stats — public network counters (peer count, models, 24h volume).

Native SDKs (coming soon)

Thin wrappers on top of the OpenAI SDKs adding balance(), peers_online(), and pinned-peer helpers. Targets: PyPI coralmesh, npm @coralmesh/sdk, NuGet CoralMesh. Subscribe via the waitlist on the landing page to be told when the first one ships.