ShareInference
← All docs

Using the API

ShareInference speaks the OpenAI chat completions protocol, so any OpenAI client works: point it at <API_PUBLIC_URL>/v1 (https://api.shareinference.com/v1 on the hosted instance) and use a ShareInference API key. The authoritative technical reference is wiki-llm/api.md; if the two disagree, the wiki wins.

Get a key

Sign in, open the dashboard and create an API key under API keys. It starts with si_ and is shown once. Keep it secret: anyone holding it spends your credits.

The examples use the hosted instance, https://api.shareinference.com, and $SI_KEY for the key. On your own install use your API_PUBLIC_URL instead (http://localhost:4401 by default).

Want to try it first? The Playground (signed in, no key needed) lets you chat with an online model in the browser and shows tokens, latency, speed and credits for every reply. It spends credits exactly like an API call.

Credits, in short

A request costs (prompt tokens × 1 + completion tokens × 5) × the model's price multiplier credits (x1 for most models, x2 for qwen3.5-9b) and the provider that served it earns the same amount. You earn credits by sharing your GPU on the Share page. Your balance may go below zero: you are then in the fair lane, served after everyone with credits, and only if your GitHub account is at least 30 days old. See the economy page for the rules, and the FAQ for every limit in one table.

List models

curl https://api.shareinference.com/v1/models -H "Authorization: Bearer $SI_KEY"

Only models with at least one provider online are listed.

Chat completion

curl https://api.shareinference.com/v1/chat/completions \
  -H "Authorization: Bearer $SI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-4b",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}],
    "max_tokens": 256
  }'

The answer is a normal chat.completion with usage. Add "stream": true (and curl's -N) to receive server-sent events ending with data: [DONE]; add "stream_options": {"include_usage": true} to get a final usage chunk.

With the OpenAI SDK

import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.SI_KEY, baseURL: "https://api.shareinference.com/v1" });

// Non-streaming
const res = await client.chat.completions.create({
  model: "qwen3.5-4b",
  messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(res.choices[0].message.content, res.usage);

// Streaming
const stream = await client.chat.completions.create({
  model: "qwen3.5-4b",
  messages: [{ role: "user", content: "Count to five." }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");

Python works the same way: OpenAI(api_key=..., base_url="https://api.shareinference.com/v1").

What is accepted

model, messages (roles system, user, assistant; text content only), stream, stream_options.include_usage, temperature, top_p, max_tokens (default 4096, at most 8192; the prompt plus max_tokens must fit the model's context window), stop, presence_penalty, frequency_penalty, seed, and enable_thinking (also read from chat_template_kwargs.enable_thinking). Any other field is rejected with a 400. Requests are limited to 256 KiB, and the prompt plus max_tokens must fit the model's context window.

Models that "think" first put that reasoning in reasoning_content (on the message, or as stream deltas) and keep it out of content. Thinking tokens are billed as output.

Errors

Errors use the OpenAI shape: {"error": {"message", "type", "code"}}.

StatuscodeMeaning
400invalid_requestUnknown field, bad value, or messages too long
401unauthorizedMissing, wrong or revoked key (a browser session does not work on /v1)
403account_too_newNo credits and your GitHub account is younger than 30 days
404model_not_foundUnknown model id
429rate_limitedToo many requests. Fair lane: 10 per minute, 500 per day, 1 at a time. With credits: 60 per minute, 4 at a time
502provider_failedThe provider failed twice before answering (or failed mid-stream)
503network_busy, no_providersThe queue is full or you waited 300 s; or no provider is online for the model

If a provider fails after it has started answering, a stream ends with one data: {"error": ...} event and you are not charged. If you close the connection, the request is cancelled: before any output arrived you are not charged; after it, you pay for the tokens you received.

Request history and votes

The dashboard lists your requests with tokens, credits and status. Once a request has succeeded it shows which provider served it, and you can vote 👍 or 👎 for that provider. Votes are private: only you see them. The same data is available to a signed-in browser at GET /api/jobs.