Quickstart
Create an API key, keep it out of your code, and make your first chat completion with cURL, Python or TypeScript.
On this page
This guide takes about five minutes. You need a BreachLine account with credit in your organization’s wallet.
1. Create an API key
- Sign in to the console.
- Open Settings, then API & Developer.
- Create a key. Give it a name that says where it will run, for example
ci-staging. - Copy the key when it is shown. It is displayed once and cannot be retrieved later.
The key dialog preselects llm:access, llm:chat and cli:knowledge:read. llm:access and llm:chat are everything this guide needs, so you can clear the others. Creating a key needs a recent sign-in: if your session is older than five minutes, the console asks for your password.
2. Store the key in an environment variable
export BREACHLINE_API_KEY="bl_live_YOUR_KEY"
3. Make a request
cURL
curl https://api.breachline.io/api/v1/llm/v1/chat/completions \
-H "Authorization: Bearer $BREACHLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nebula-4.5",
"messages": [
{"role": "system", "content": "You are a concise security assistant."},
{"role": "user", "content": "What should I check first on a login form?"}
]
}'
Python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BREACHLINE_API_KEY"],
base_url="https://api.breachline.io/api/v1/llm/v1",
)
response = client.chat.completions.create(
model="nebula-4.5",
messages=[
{"role": "system", "content": "You are a concise security assistant."},
{"role": "user", "content": "What should I check first on a login form?"},
],
)
print(response.choices[0].message.content)
TypeScript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.BREACHLINE_API_KEY,
baseURL: 'https://api.breachline.io/api/v1/llm/v1',
});
const response = await client.chat.completions.create({
model: 'nebula-4.5',
messages: [
{ role: 'system', content: 'You are a concise security assistant.' },
{ role: 'user', content: 'What should I check first on a login form?' },
],
});
console.log(response.choices[0].message.content);
A successful call returns a chat.completion object. Every response carries an X-Request-ID header; quote it if you contact support.
4. Stream the answer
Add stream: true to receive tokens as they are generated, as server-sent events.
stream = client.chat.completions.create(
model="nebula-4.5",
messages=[{"role": "user", "content": "List three common causes of SSRF."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content if chunk.choices else None
if delta:
print(delta, end="", flush=True)
See Streaming for the event format and how errors arrive mid-stream.
If something goes wrong
| Status | Meaning | Fix |
|---|---|---|
401 |
The key is missing, mistyped, expired or revoked. | Check the header and the key’s status in the console. |
402 |
The organization has no spendable credit, or its spend cap is reached. | Top up in Settings, Billing & Credits, or raise the cap. |
403 |
The key lacks a scope, for example llm:chat. |
Create a key with the right scopes. |
429 |
A rate limit was hit. | Back off and retry; see Rate limits. |
Next steps
- Learn the key lifecycle and scopes.
- Choose a model.
- Make retries safe with idempotency keys.
- Browse the API reference.