AgentCost API

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.

POSThttps://agentcostai.eu/v1/chat/completions
Keep your key private. Client keys start with ac_live_. Store them in an environment variable on your server—never in browser code, mobile apps, public repositories, screenshots, or support messages.

Quick start

Subscribe to AgentCost Pro

Complete checkout and wait for the AgentCost success page.

Copy the client API key

Your new ac_live_... key is displayed during activation. Save it securely.

Add the key to your server
AGENTCOST_API_KEY=ac_live_your_key_here
Send your first request

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

FieldRequiredDescription
modelYesA model supported by the configured provider.
messagesYesConversation messages with a role and content.
temperatureNoControls response variation where supported.
max_tokensNoLimits 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

ResultWhat to check
401 UnauthorizedThe Bearer key is missing, malformed, revoked, or invalid.
Non-2xx budget responseThe client may have reached a daily or monthly budget limit. Check the portal.
Provider errorVerify the model name, request fields, and provider availability.
5xx responseRetry 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.

Need help? Contact support@avivar.io. Never include full card data, provider secret keys, or your complete AgentCost client key.