# The cheapest way to use GPT and Claude through an API

> Use GPT and Claude for less: pick the cheapest tier that does the job, cap max_tokens and budgets, and see the exact cost of every call.

**The cheapest way to use GPT and Claude through an API is to route requests through a unified, OpenAI-compatible gateway that bills each call at the lab's list price plus a small AI fee, and to use lightweight tiers like GPT-6 Luna and Claude Haiku 5.5 at $0.10 per million input tokens.** Instead of funding separate developer accounts across multiple providers, you keep a single prepaid balance and point your existing client at one base URL. You pay only for the exact tokens you consume, with safety caps to prevent runaway spend.

Managing accounts across multiple AI providers creates unnecessary friction and hidden costs. Unused account credits sit idle across separate billing dashboards, client libraries multiply across your codebase, and small automated tasks accidentally burn expensive reasoning tokens. Using a consolidated gateway lets you optimize your token spend across both model families from day one.

## What do GPT and Claude cost per million tokens?

API pricing is determined by model capability and output size. Fast, lightweight models handle high-frequency work like intent detection, text classification, and structured data extraction at a fraction of the cost of flagship reasoning tiers.

Here is the baseline list pricing for the standard OpenAI and Anthropic tiers available through the thelastapi gateway:

| thelastapi model | Underlying lab model | Best suited for | Price per million tokens (in / out) |
| --- | --- | --- | --- |
| `vibiz/fast` | GPT-6 Luna (OpenAI) | Chat, tool calls, JSON extraction | $0.10 / $0.50 |
| `vibiz/smart-mini` | Claude Haiku 5.5 (Anthropic) | Quick tasks, drafting, lightweight coding | $0.10 / $0.50 |
| `vibiz/reasoning` | GPT-6.1 Terra (OpenAI) | Complex logic, planning, multi-step math | $1.00 / $5.00 |
| `vibiz/smart` | Claude Sonnet 5.5 (Anthropic) | Hard tasks, coding, agents, long writing | $2.00 / $10.00 |
| `vibiz/pro` | Claude Opus 5.5 (Anthropic) | Deep analysis, evaluation, long agent runs | $4.00 / $20.00 |

Usage is billed against your prepaid balance at what the call costs plus a 10% AI fee. Every new account begins with $2 of trial credit, which allows you to run millions of tokens through entry tiers before adding funds.

Keep input context thresholds in mind when calculating high-volume workload costs. Some models apply long-context rates when requests grow very large. On GPT-6 models, long-context pricing applies once input passes 272,000 tokens. On Claude Haiku 5.5, the higher rate applies past 100,000 input tokens. For routine tasks, trimming system prompts and keeping context concise ensures your calls remain on the lowest base tier.

## How to route requests to the most affordable tier

To minimize your bill, match every task to the smallest model that can complete it reliably. Defaulting to Claude Sonnet or Claude Opus for routine background tasks quickly drives up costs without delivering noticeable quality gains:

1. **Use `vibiz/fast` or `vibiz/smart-mini` for structured work.** Extracting fields, formatting JSON, filtering inbound text, and simple conversational turns cost just $0.10 per million input tokens. Running 100,000 input tokens a day on these tiers costs one cent.
2. **Step up to `vibiz/smart` only for nuanced reasoning.** Reserve Claude Sonnet 5.5 ($2.00 / $10.00) for multi-file code editing, complex synthesis, and agentic workflows where smaller models struggle.
3. **Save `vibiz/reasoning` and `vibiz/pro` for edge cases.** GPT-6.1 Terra ($1.00 / $5.00) and Claude Opus 5.5 ($4.00 / $20.00) provide deep analysis, but their cost per token is much higher.

Because the interface is standardized, changing models in your application requires updating only a single parameter. For a closer look at multi-provider routing patterns, read [One API key for GPT, Claude and Gemini: how a unified AI API works](https://thelastapi.dev/blog/one-api-key-gpt-claude-gemini) and our guide on an [OpenAI-compatible API for Claude and Gemini: change one base URL](https://thelastapi.dev/blog/openai-compatible-api-claude-gemini).

## How to call both labs through the OpenAI SDK

You do not need to install the Anthropic SDK or learn different parameter names to use Claude. The gateway operates at `/v1/ai` as an OpenAI-compatible interface, supporting streaming completions, tool calling, and structured JSON output.

Configure your standard `openai` package using environment variables provided by the platform:

```bash
npm install openai
```

```ts
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: process.env.VIBIZ_AI_BASE_URL,
  apiKey: process.env.VIBIZ_AI_API_KEY,
});

async function runAffordableChat() {
  // Call GPT-6 Luna for inexpensive structured classification
  const gptResponse = await openai.chat.completions.create({
    model: 'vibiz/fast',
    messages: [
      { role: 'system', content: 'Extract intent as JSON.' },
      { role: 'user', content: 'Cancel subscription for acme' },
    ],
    response_format: { type: 'json_object' },
  });

  console.log('GPT result:', gptResponse.choices[0]?.message.content);

  // Call Claude Haiku 5.5 using the exact same client
  const claudeResponse = await openai.chat.completions.create({
    model: 'vibiz/smart-mini',
    messages: [
      { role: 'user', content: 'Draft a short, one-sentence receipt confirmation.' },
    ],
  });

  console.log('Claude result:', claudeResponse.choices[0]?.message.content);
}

runAffordableChat();
```

If your application uses `@vibiz/app`, pass `vibiz.ai` directly to your client without manual environment configuration:

```ts
import { vibiz } from '@vibiz/app';
import OpenAI from 'openai';

const openai = new OpenAI(vibiz.ai);
```

You can also send requests via curl to `https://thelastapi.dev/v1/ai/chat/completions`:

```bash
curl https://thelastapi.dev/v1/ai/chat/completions \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H 'content-type: application/json' \
  -d '{"model":"vibiz/smart-mini","messages":[{"role":"user","content":"Hi"}]}'
```

Every model request routes to the exact model specified. If a lab experiences an outage, the gateway returns a `model_unavailable` or `provider_unavailable` error rather than silently routing your prompt to an unexpected, expensive fallback. Review complete request shapes on the [AI documentation page](https://thelastapi.dev/docs/ai).

## How to prevent runaway spend with daily caps and budgets

The fastest way to ruin API cost efficiency is an unmonitored script or agent trapped in an infinite loop. thelastapi enforces guardrails at both the account and project levels:

- **Account daily safety cap:** Accounts default to a $5 daily safety ceiling across AI and background actions. An owner can raise this limit in the console or by sending a request:
  ```bash
  curl -X PATCH https://thelastapi.dev/v1/billing \
    -H "Authorization: Bearer $VIBIZ_API_KEY" \
    -H 'content-type: application/json' \
    -d '{"daily_spend_limit_usd": 25}'
  ```
  The cap can be set up to $1,000. If exceeded, requests return an HTTP `429` status with `details.reason: "daily_spend"`.
- **Project AI daily budget:** Individual projects default to a $1 daily AI budget. An owner can adjust this limit with the CLI:
  ```bash
  vibiz ai budget 10 --project prj_123
  ```
- **Spend alerts:** Account owners receive an automated alert email at 80% and 100% of any daily cap, including direct links to adjust the limit.

To learn how to handle backoff and throttling when caps are reached, read [How to handle rate limits on LLM APIs](https://thelastapi.dev/blog/handle-llm-rate-limits), or review configuration details under [Usage and limits](https://thelastapi.dev/docs/usage).

## How to track token costs down to the micro-dollar

Most provider consoles display delayed billing charts, making it difficult to pinpoint which user, prompt, or function generated unexpected charges.

thelastapi returns the exact cost of each completion directly in the JSON response body:
- `cost_micro_usd`: The exact execution cost represented in micro-dollars (where 1,000,000 micro-dollars equal $1.00).
- `served_model`: The specific underlying model that processed your prompt.

You can inspect spending directly from your terminal using the CLI:

```bash
# Check usage grouped by model for the last 7 days
vibiz usage --period 7d --by model

# Check usage broken down by end user
vibiz usage --by end_user --project prj_123
```

By passing a user identifier inside the `user` property of your chat completion payload, you can isolate spend per customer and enforce individual limits using `end_user_daily_budget_usd`. Read more on prepaid balance handling under [Billing and credits](https://thelastapi.dev/docs/billing).

## How to test and search models from the CLI

Before committing a specific model tier to production code, test prompt performance and verify real-time costs directly from your terminal:

```bash
# Stream an answer from Claude Haiku 5.5
vibiz ai "Summarize this log line" --model vibiz/smart-mini

# Stream an answer from GPT-6 Luna
vibiz ai "Summarize this log line" --model vibiz/fast

# Search the entire catalogue of over 400 models
vibiz ai models claude
```

The CLI prints the response stream alongside the final micro-dollar cost, letting you compare the performance and cost of GPT and Claude models in seconds.

Next, explore how to structure keys securely in [Keys and environments](https://thelastapi.dev/docs/keys), or set up a complete project locally with `vibiz init "My Project" --resources ai`.

## Frequently asked questions

### Can I use the Anthropic Claude SDK with the gateway?

No, the gateway provides an OpenAI-compatible interface under `/v1/ai`, so you use the standard OpenAI SDK or `@vibiz/app` to call both Claude and GPT models. This lets you switch between OpenAI and Anthropic models simply by updating the model parameter.

### What happens if an API call exceeds my account balance?

Each call is checked against your account balance before running based on its worst-case token limit. If the worst case exceeds your credits by more than $0.50, the request is refused with a `402 payment_required` error instead of running up an unexpected negative balance.

### How do I call a specific Claude or GPT model version not listed in the default tiers?

Beyond the standard tiers like `vibiz/fast` and `vibiz/smart`, you can pass any specific lab identifier directly in the model field, such as `anthropic/claude-opus-5.5`. The gateway supports over 400 models from all major labs.

### Does the gateway fall back to a cheaper model if Claude or GPT is down?

No, thelastapi never silently swaps your requested model for a different one. If the specified model cannot run, the gateway returns an error like `model_unavailable` or `provider_unavailable` with a retry hint.

---

Published 2026-11-15 · https://thelastapi.dev/blog/cheapest-way-gpt-claude-api
