Skip to main content
    Quickstart

    Add AI to Your App in 5 Minutes

    Get your API key, make your first call, and ship AI features. No backend required.

    Prerequisites

    • A Behest AI account (free, sign up at behest.ai/dashboard — no credit card required)
    • Any HTTP client — fetch, axios, requests, curl, or your language of choice

    1Get Your API Key

    1. Sign up at behest.ai/dashboard
    2. Create a new project
    3. Configure your allowed CORS origins (e.g., http://localhost:3000 for local development)
    4. Copy your project API key

    Your project URL will look like https://your-project.behest.app

    2Make Your First API Call

    Two headers to attribute every request

    Behest groups token usage and cost by X-End-User-Id (the end user) and X-Session-Id (the conversation thread). Set both on every request so your dashboard can show per-user and per-session spend instead of one aggregate bucket.

    Use any unique identifier for X-Session-Id — typically a chat session ID or a user-{userId}-conv-{conversationId} pair. The header is optional, but skipping it collapses every request into a single “no session” bucket in your analytics.

    JavaScript (fetch)

    const response = await fetch(
      "https://your-project.behest.app/v1/chat/completions",
      {
        method: "POST",
        headers: {
          "Authorization": "Bearer your-api-key",
          "Content-Type": "application/json",
          "X-End-User-Id": userId,
          // Uniquely identifies a conversation thread for per-session cost attribution.
          "X-Session-Id": `user-${userId}-conv-${conversationId}`,
        },
        body: JSON.stringify({
          model: "gemini-2.5-flash",
          messages: [
            { role: "user", content: "Summarize this contract" }
          ],
        }),
      }
    );
    
    const data = await response.json();
    console.log(data.choices[0].message.content);

    Python (requests)

    import requests
    
    response = requests.post(
        "https://your-project.behest.app/v1/chat/completions",
        headers={
            "Authorization": "Bearer your-api-key",
            "Content-Type": "application/json",
            "X-End-User-Id": user_id,
            # Uniquely identifies a conversation thread for per-session cost attribution.
            "X-Session-Id": f"user-{user_id}-conv-{conversation_id}",
        },
        json={
            "model": "gemini-2.5-flash",
            "messages": [
                {"role": "user", "content": "Summarize this contract"}
            ],
        },
    )
    
    data = response.json()
    print(data["choices"][0]["message"]["content"])

    curl

    # X-Session-Id uniquely identifies a conversation thread for
    # per-session cost attribution in your analytics dashboard.
    curl -X POST https://your-project.behest.app/v1/chat/completions \
      -H "Authorization: Bearer your-api-key" \
      -H "Content-Type: application/json" \
      -H "X-End-User-Id: user-123" \
      -H "X-Session-Id: user-123-conv-abc" \
      -d '{
        "model": "gemini-2.5-flash",
        "messages": [
          {"role": "user", "content": "Summarize this contract"}
        ]
      }'

    3What Happens Automatically

    When you make that API call, Behest handles everything behind the scenes:

    CORS handled Browser requests just work
    Auth validated API key verified, tenant isolated
    PII scrubbed Sensitive data detected and protected
    Prompts defended Injection attacks blocked
    Rate limits enforced Per-IP, per-project, per-user
    Memory persisted Conversation context maintained
    Tokens tracked Usage and spend recorded
    Fully observable Traces, metrics, and logs captured

    Next Steps

    Enterprise Token FinOps: Enforce hard budgets and attribute costs per session.

    Learn more