Quickstart Guide

Attenval provides an OpenAI-compatible API layer powered by dynamic multi-provider routing. You can earn promotional credits through verified engagement or purchase persistent credits, and spend them seamlessly via standard OpenAI client libraries.


1. Obtain Your API Key

  1. Sign in to your account at app.attenval.com.
  2. Navigate to API Keys in the sidebar.
  3. Click Create API Key, specify an optional daily credit cap, and copy your secret key:
    • Live key format: atv_live_...
    • Test key format: atv_test_...

Security Note: Your full key secret is displayed only once upon generation. Attenval stores only salted SHA-256 hashes of keys.


2. Check Your Credit Balance

Before making inference calls, verify your account balance using the /v1/credits endpoint.

curl https://api.attenval.com/v1/credits \
  -H "Authorization: Bearer atv_live_YOUR_API_KEY"

Example Response

{
  "account_id": "acc_8f93a2e1",
  "total_credits": 145950,
  "earned_credits": {
    "balance": 18450,
    "expires_at": "2026-09-27T12:00:00Z",
    "status": "active"
  },
  "purchased_credits": {
    "balance": 127500,
    "expires_at": null,
    "status": "active"
  },
  "currency": "ATTENVAL_CREDITS"
}

3. Make Your First Chat Completion

Attenval is drop-in compatible with standard OpenAI SDKs. Set the baseURL to https://api.attenval.com/v1 and use any of our unified model aliases (attenval-auto, attenval-fast, attenval-code, attenval-smart).

cURL

curl https://api.attenval.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer atv_live_YOUR_API_KEY" \
  -d '{
    "model": "attenval-auto",
    "messages": [
      { "role": "system", "content": "You are a concise technical assistant." },
      { "role": "user", "content": "Explain how token bucketing works in rate limiters." }
    ],
    "temperature": 0.7,
    "max_tokens": 300
  }'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="atv_live_YOUR_API_KEY",
    base_url="https://api.attenval.com/v1"
)

response = client.chat.completions.create(
    model="attenval-auto",
    messages=[
        {"role": "system", "content": "You are a concise technical assistant."},
        {"role": "user", "content": "Explain how token bucketing works in rate limiters."}
    ],
    temperature=0.7,
    max_tokens=300
)

print(response.choices[0].message.content)

Node.js / TypeScript (OpenAI SDK)

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'atv_live_YOUR_API_KEY',
  baseURL: 'https://api.attenval.com/v1',
});

async function main() {
  const completion = await client.chat.completions.create({
    model: 'attenval-auto',
    messages: [
      { role: 'system', content: 'You are a concise technical assistant.' },
      { role: 'user', content: 'Explain how token bucketing works in rate limiters.' },
    ],
    max_tokens: 300,
  });

  console.log(completion.choices[0]?.message.content);
}

main();

4. Understanding Response Metadata

Every successful completion returns standard OpenAI formatting along with custom Attenval usage headers and JSON metadata:

{
  "id": "chatcmpl-atv-9f8a3d12bc",
  "object": "chat.completion",
  "created": 1786845600,
  "model": "attenval-auto",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Token bucketing is an algorithm where tokens accumulate at a fixed rate in a bucket..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 84,
    "total_tokens": 112
  },
  "attenval": {
    "requested_model": "attenval-auto",
    "routed_model": "deepseek-ai/deepseek-v3",
    "credits_used": 18,
    "balance_remaining": 145932,
    "latency_ms": 342
  }
}

Next Steps