Connect in minutes
AgentCost exposes an OpenAI-compatible chat completions endpoint. Change your base URL, use your AgentCost client key, and keep the rest of your integration familiar.
https://agentcostai.eu/v1/chat/completionsac_live_. Store them in an environment variable on your server—never in browser code, mobile apps, public repositories, screenshots, or support messages.Quick start
Complete checkout and wait for the AgentCost success page.
Your new ac_live_... key is displayed during activation. Save it securely.
AGENTCOST_API_KEY=ac_live_your_key_here
Choose one of the examples below. Successful responses follow the OpenAI chat completions shape.
cURL
curl https://agentcostai.eu/v1/chat/completions \
-H "Authorization: Bearer $AGENTCOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Summarize this in one sentence."}
]
}'Node.js — OpenAI SDK
Install the official SDK:
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AGENTCOST_API_KEY,
baseURL: "https://agentcostai.eu/v1"
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "user", content: "Write a short customer follow-up." }
]
});
console.log(response.choices[0].message.content);Python — OpenAI SDK
Install the official SDK:
pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AGENTCOST_API_KEY"],
base_url="https://agentcostai.eu/v1"
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "Create a three-item checklist."}
]
)
print(response.choices[0].message.content)JavaScript — fetch
const response = await fetch(
"https://agentcostai.eu/v1/chat/completions",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.AGENTCOST_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gpt-4o-mini",
messages: [
{ role: "user", content: "Explain this result simply." }
]
})
}
);
if (!response.ok) {
throw new Error(`AgentCost error ${response.status}: ${await response.text()}`);
}
const data = await response.json();
console.log(data.choices[0].message.content);Request format
| Field | Required | Description |
|---|---|---|
model | Yes | A model supported by the configured provider. |
messages | Yes | Conversation messages with a role and content. |
temperature | No | Controls response variation where supported. |
max_tokens | No | Limits generated output where supported. |
Other provider-compatible parameters may be forwarded when supported. Start with the minimal request above before adding optional fields.
Errors and limits
| Result | What to check |
|---|---|
| 401 Unauthorized | The Bearer key is missing, malformed, revoked, or invalid. |
| Non-2xx budget response | The client may have reached a daily or monthly budget limit. Check the portal. |
| Provider error | Verify the model name, request fields, and provider availability. |
| 5xx response | Retry later with exponential backoff and a request timeout. |
Security checklist
- Use one AgentCost key per client or environment.
- Keep keys only in server-side environment variables or a secrets manager.
- Never expose a key inside public JavaScript or a mobile application.
- Set daily and monthly budgets before production traffic.
- Rotate or revoke a key if it may have been exposed.
- Do not send sensitive or regulated data unless your provider and legal configuration permit it.
Client portal and billing
Open the Client Portal to review usage, cost, budgets, and estimated savings. Use the billing option inside the portal to update payment details or cancel the subscription through Stripe.