> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get an AI response in 30 seconds. No SDK needed — just HTTP.

## 1. Get your API key

Go to [dashboard.chipipay.com](https://dashboard.chipipay.com), create an org, and copy your API key from the Credentials page.

## 2. Make your first call

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.chipipay.com/v1/ai/chat \
    -H "Authorization: Bearer sk_prod_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o-mini",
      "messages": [{"role": "user", "content": "What is Starknet?"}]
    }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://api.chipipay.com/v1/ai/chat", {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_prod_YOUR_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "gpt-4o-mini",
      messages: [{ role: "user", content: "What is Starknet?" }],
    }),
  });

  const data = await response.json();
  console.log(data.text);
  // → "Starknet is a Layer 2 scaling solution for Ethereum..."
  console.log(data.cost.charged);
  // → 0.00001 (USD)
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.chipipay.com/v1/ai/chat",
      headers={"Authorization": "Bearer sk_prod_YOUR_KEY"},
      json={
          "model": "gpt-4o-mini",
          "messages": [{"role": "user", "content": "What is Starknet?"}],
      },
  )

  data = response.json()
  print(data["text"])
  print(f"Cost: ${data['cost']['charged']}")
  ```
</CodeGroup>

## 3. Stream a response

For chatbots and real-time UIs, use the streaming endpoint — same request body, token-by-token delivery via SSE:

<CodeGroup>
  ```bash cURL theme={null}
  curl -N -X POST https://api.chipipay.com/v1/ai/chat/stream \
    -H "Authorization: Bearer sk_prod_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "haiku", "messages": [{"role": "user", "content": "Tell me a joke"}]}'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://api.chipipay.com/v1/ai/chat/stream", {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_prod_YOUR_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "haiku",
      messages: [{ role: "user", content: "Tell me a joke" }],
    }),
  });

  const reader = response.body!.getReader();
  const decoder = new TextDecoder();
  let buffer = "";

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    buffer += decoder.decode(value, { stream: true });
    const lines = buffer.split("\n");
    buffer = lines.pop() ?? "";

    for (const line of lines) {
      if (!line.startsWith("data: ")) continue;
      const data = JSON.parse(line.slice(6));

      if (data.done) {
        console.log("Cost:", data.cost.charged, "USD");
      } else {
        console.log(data.text); // append to your UI
      }
    }
  }
  ```
</CodeGroup>

## 4. Buy credits

AI calls debit from your org's credit balance. Buy a credit pack ($2 / $5 / $25 / $50 / \$100) at [dashboard.chipipay.com/configure/billing](https://dashboard.chipipay.com/configure/billing) by sending USDC.

\$5 gets you **\~50,000 calls** with `gpt-4o-mini` or **\~700 calls** with `haiku`.

## Auth

Two options — both work on all AI endpoints, no JWKS setup needed:

| Method     | Header                              | Best for                      |
| ---------- | ----------------------------------- | ----------------------------- |
| Secret key | `Authorization: Bearer sk_prod_...` | Server-side (backend, agent)  |
| Public key | `x-api-key: pk_prod_...`            | Client-side (browser, mobile) |

<Warning>
  Never put `sk_` keys in client-side code. Use `pk_` for browser/mobile apps.
</Warning>

## What you can build

| Use case                  | Endpoint                                                                | Cost                                  |
| ------------------------- | ----------------------------------------------------------------------- | ------------------------------------- |
| Chatbot / code assistant  | [`POST /ai/chat`](/services/ai-api/chat-and-streaming)                  | Per token                             |
| Real-time streaming UI    | [`POST /ai/chat/stream`](/services/ai-api/chat-and-streaming#streaming) | Per token                             |
| DeFi portfolio advisor    | [`POST /ai/think`](/services/ai-api/defi-intelligence)                  | Per token                             |
| Swap execution            | [`POST /ai/execute`](/services/ai-api/defi-intelligence#execute-a-swap) | \$0.002/call                          |
| Token prices for wallets  | [`GET /ai/prices`](/services/ai-api/prices-and-data)                    | Free                                  |
| Market signals for agents | [`GET /ai/signals`](/services/ai-api/prices-and-data#technical-signals) | Free up to 100/mo, then \$0.0005/call |

## Next

* [Chat & Streaming](/services/ai-api/chat-and-streaming) — full request/response reference
* [DeFi Intelligence](/services/ai-api/defi-intelligence) — portfolio advisor + swap execution
* [Prices & Data](/services/ai-api/prices-and-data) — 90 tokens, 11 chains, 60 currencies
* [Models & Pricing](/services/ai-api/models) — all models, providers, and rate limits
