Docs
AI Provider is a private AI you reach with a key. You send a message, you get a reply, and we never store either one. It speaks the same language as OpenAI's API, so most AI apps and code libraries already know how to talk to it.
Use it in an app
Many apps let you bring your own AI key: chat apps, writing tools, story and character apps, automation tools and coding assistants. Open the app's settings and look for something like "OpenAI-compatible", "custom endpoint" or "base URL". Then fill in three boxes:
- Address (base URL)
https://api.aiprovider.org/v1- API key
- Your key, which starts with
ap_. Make one if you need it. - Model
aiprovider-1
Where it goes in each kind of app
Chat appsA private chat screen on your computer, phone or home server.
- Open Settings and find Connections, Models or API. Add a new connection and pick "OpenAI" or "OpenAI-compatible".
- Paste the address into the box called Base URL, API URL or Endpoint.
- Paste your key into the API key box, then choose the model aiprovider-1 and start a new chat.
Writing appsDrafting and editing tools that let you bring your own key.
- Look for "Use your own key", "Custom model" or "OpenAI-compatible" in the app settings.
- Paste the address where it asks for a base URL or server.
- Paste your key, set the model name to aiprovider-1, and save. Try a short request first.
Story & character appsInteractive fiction, role-play and character chats.
- Open the API or connection settings and choose "Chat completion", then "Custom (OpenAI-compatible)".
- Paste the address into the custom endpoint box.
- Paste your key, pick aiprovider-1 from the model list, and press Connect.
Automation toolsWorkflows that read, sort and write for you while you sleep.
- Add an "OpenAI" step or credential to your workflow.
- Change its base URL to the address below. Some tools hide this under "advanced options".
- Paste your key as the API key and type aiprovider-1 as the model.
Coding assistantsEditor helpers that accept a custom endpoint.
- In the assistant settings, add a provider and choose "OpenAI-compatible".
- Paste the address as the base URL.
- Paste your key and add aiprovider-1 as the model. The Docs have tips for tool calling.
Your own codeAny program that can use the official OpenAI libraries.
- Install the OpenAI library for Python or JavaScript, or use plain HTTP.
- Set base_url (baseURL in JavaScript) to the address.
- Use your key as the API key and aiprovider-1 as the model. The Docs show full examples.
Good to know: the AI thinks briefly before it answers. Most apps hide that thinking and show only the answer, which is what you want. If an app asks for a list of models, it finds aiprovider-1 on its own.
Quick start for code
If your code already uses the OpenAI format, change the address, the key and the model name. That's it.
- Get a key. It shows on screen right away and starts with
ap_. - Save it as an environment variable (a setting your program reads), for example
AIPROVIDER_API_KEY. - Send a request to
https://api.aiprovider.org/v1/chat/completionswith the modelaiprovider-1.
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiprovider.org/v1",
api_key=os.environ["AIPROVIDER_API_KEY"],
)
reply = client.chat.completions.create(
model="aiprovider-1",
messages=[{"role": "user", "content": "Write a two-line welcome for our help desk."}],
)
print(reply.choices[0].message.content)You get back a normal chat completion:
{
"id": "chatcmpl-8kq3...",
"object": "chat.completion",
"model": "aiprovider-1",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"reasoning_content": "They want something short and warm...",
"content": "Hi, you've reached the help desk.\nTell us what's going on and we'll sort it out."
},
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 22, "completion_tokens": 61, "total_tokens": 83 }
}Reasoning and replies
The model thinks for a moment before it answers. Replies include a short reasoning step, billed as output tokens. It comes back in its own field, so it never mixes with the answer:
message.contentis the answer. Show this to your users.message.reasoning_contentis the reasoning step. Show it, keep it on your side, or ignore it.
If a reply runs out of room (it reaches max_tokens) while the model is still thinking, everything so far is in reasoning_content, content is empty, and finish_reason is length. Give it more room and try again. We suggest at least 1,000 tokens for short answers.
Streaming
Set "stream": true to get the reply piece by piece as it's written, using server-sent events (a simple standard for streaming text over HTTP). The reasoning arrives first in delta.reasoning_content, then the answer in delta.content.
stream = client.chat.completions.create(
model="aiprovider-1",
messages=[{"role": "user", "content": "Explain DNS in three sentences."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta
# The short reasoning step arrives first (delta.reasoning_content), then the answer.
if delta.content:
print(delta.content, end="", flush=True)Add "stream_options": {"include_usage": true} to get a final chunk with token counts. The stream ends with data: [DONE].
Tool calling
Tool calling lets the AI ask your program to do something, like look up the weather or search your files, and then use the answer. Send tools the usual way and read tool_calls from the reply. Streaming works too.
Parameters
We accept these fields on POST /v1/chat/completions. Others are ignored.
| Field | What it does |
|---|---|
model | Use aiprovider-1. Any other name is treated as this one, unless you pass a model from the credit catalog — then the request runs on that model and pays with credits. |
messages | The conversation: system, user, assistant and tool messages. Text only. |
max_tokens | Longest reply, reasoning included. Up to 131,072, which is also the default. max_completion_tokens works too. |
temperature, top_p | How adventurous the wording is. Lower is more predictable. |
stop | Up to 4 strings. The answer ends just before the first one appears. |
seed | Ask for repeatable output. Best effort, not a guarantee. |
response_format | {"type": "json_object"} asks for valid JSON. Also say "reply in JSON" in your prompt. |
tools, tool_choice, parallel_tool_calls | See the tool calling guide. The older functions and function_call work too. |
stream, stream_options | See Streaming. |
n | Must be 1 (one reply per request). |
Errors
Errors use the usual shape, so the official libraries raise the right exception. The message says what went wrong and what to do.
{
"error": {
"message": "You're out of credit. Add credit at https://aiprovider.org/dashboard/billing and try again.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota"
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_value, invalid_messages | Something in the request is wrong. The message names the field. |
| 400 | unsupported_content | The request had an image, audio or file. Text only. |
| 400 | context_length_exceeded | More than 1,048,576 tokens of context. Shorten the conversation. |
| 400 | content_policy_violation | Blocked by our safety rule on minors. See acceptable use. |
| 401 | invalid_api_key, key_disabled | Missing, wrong or switched-off key. Manage your keys. |
| 402 | insufficient_quota | Out of credit. Add credit and try again. |
| 402 | key_cap_reached | This key reached the monthly cap you set. Raise it on the Keys page. |
| 403 | account_suspended | The account is suspended. The message has our support address. |
| 413 | request_too_large | The request is over about 4.5 MB. Split it into smaller requests. |
| 429 | rate_limit_exceeded | Too many requests at once or per minute for your plan. |
| 429 | server_busy | Our GPUs are full for a moment. Wait the seconds in the Retry-After header. |
| 503 | model_unavailable | The model is briefly unavailable. Retry after a few seconds. |
For 429 and 503, retry with a growing wait: 1 second, then 2, then 4, or the number in Retry-After. The official libraries do this for you.
Limits
Limits depend on your plan. "At once" means requests still running at the same moment.
| Plan | At once | Per minute |
|---|---|---|
| Pay as you go | 2 | 30 |
| Pro | 4 | 60 |
| Business | 8 | 120 |
- Context: up to 1,048,576 tokens per request. We estimate about 4 characters per token.
- Request size: up to about 4.5 MB of JSON, roughly 1 million tokens of plain text. That is enough to fill the whole context window.
- Reply: up to 131,072 tokens, reasoning included.
- Time: a request can run for up to about 13 minutes. Very long replies may stop there; stream them and keep what arrives.
- Busy times: your request may wait in line for up to 2 minutes before it starts. Streaming requests stay connected while they wait.
Your balance
GET /v1/account tells you how much credit is left, what you've spent this month, your plan and your limits. Use the same key. Amounts are in US dollars.
curl https://api.aiprovider.org/v1/account \
-H "Authorization: Bearer $AIPROVIDER_API_KEY"The same numbers, with charts, are in your dashboard.
Not supported yet
- Images, audio and files: messages must be text.
- Embeddings and fine-tuning: only chat completions for now.
- More than one reply per request (
nabove 1).
Need one of these? Tell us at the support address in the footer. It helps us decide what to build next.