BaseURL docs
BaseURL is an OpenAI-compatible API for open-source AI models. One API key reaches every model, and you pay in naira through Paystack. If your code already uses an OpenAI SDK, you change two things: the base URL and the key.
| Base URL | https://api.baseurl.dev/v1 |
| Authentication | Authorization: Bearer YOUR_BASEURL_KEY |
| Endpoints | POST /v1/chat/completions, GET /v1/models |
| Billing | Prepaid balance, topped up in naira; usage priced in USD per million tokens |
Quickstart
- Create an account at app.baseurl.dev. New accounts are reviewed, usually within 5 minutes, and get a welcome credit when approved.
- Create an API key on the API keys page. The full key is shown once: store it somewhere safe, such as an environment variable.
- Make your first request. Install the SDK with
pip install openaiornpm install openai; theopenailibrary works with any compatible API.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.baseurl.dev/v1",
api_key="YOUR_BASEURL_KEY",
)
reply = client.chat.completions.create(
model="gateway-fast",
messages=[{"role": "user", "content": "Explain recursion in one sentence."}],
max_tokens=200,
)
print(reply.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.baseurl.dev/v1",
apiKey: process.env.BASEURL_KEY,
});
const reply = await client.chat.completions.create({
model: "gateway-fast",
messages: [{ role: "user", content: "Explain recursion in one sentence." }],
max_tokens: 200,
});
console.log(reply.choices[0].message.content);
cURL
curl https://api.baseurl.dev/v1/chat/completions \
-H "Authorization: Bearer $BASEURL_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gateway-fast",
"messages": [{"role": "user", "content": "Explain recursion in one sentence."}],
"max_tokens": 200
}'
Want to try a model before writing code? Use the Playground in your dashboard.
Next
- Chat completions: parameters, streaming, response headers, retries.
- Models: which model to pick.
- Errors: every error code and what to do.
- Billing and limits: how charging, top-ups and limits work.
Questions? Email [email protected] with your X-Request-Id.