thelastapi
Get started free

Which LLM API is best for agentic tool use?

For agentic tool use, Claude Sonnet 5.5 handles complex multi-step workflows while GPT-6 Luna offers fast, low-cost execution with structured JSON.

On this page 6 sections

For long, multi-step agent work, start with a strong tier like vibiz/smart (Claude Sonnet 5.5) or vibiz/pro (Claude Opus 5.5); for high-volume, simple tool calls, a cheap tier like vibiz/fast (GPT-6 Luna) is usually enough. Which model API is best depends on whether your agent is writing software, orchestrating multi-step plans, or executing high-frequency lookups. Through thelastapi, you can call any of these models via a single OpenAI-compatible endpoint at /v1/ai without managing separate credentials across labs.

When building an autonomous agent, model choice affects not only reasoning quality, but latency, token cost, and tool reliability. Below is a breakdown of how the leading models perform on agentic tool calling and how to wire them up to real tools.

How tool calling models compare across agent workflows

Agentic tool use requires two distinct capabilities: deciding when and which function to invoke with precise arguments, and maintaining context across chained calls without hallucinating.

The table below outlines the core tiers available via thelastapi gateway:

thelastapi modelRuns onGood forPrice per million tokens (in / out)
vibiz/smartClaude Sonnet 5.5 (Anthropic)writing, coding, agents$2 / $10
vibiz/proClaude Opus 5.5 (Anthropic)the strongest tier$4 / $20
vibiz/fastGPT-6 Luna (OpenAI)chat, tool calls, JSON$0.10 / $0.50
vibiz/balancedGemini 3.8 Flash (Google)quality and price balanced$0.825 / $4.125
vibiz/liteDeepSeek V4.1 Flashthe cheapest chat, 1M context$0.14 / $0.42

Deep reasoning and complex workflows: Claude Sonnet 5.5

For agents tasked with autonomous coding, debugging, or following complex business workflows, vibiz/smart (Anthropic's Claude Sonnet 5.5) is built for agentic tasks. It excels at following strict parameter constraints and sequencing multiple tool calls in sequence. When your workflow requires the strongest tier of reasoning, you can step up to vibiz/pro (Claude Opus 5.5).

High-frequency execution: GPT-6 Luna

If your agent runs tight execution loops—such as parsing inputs, making rapid database lookups, or outputting JSON objects—latency and token costs matter more than long-range reflection. vibiz/fast (OpenAI's GPT-6 Luna) costs $0.10 per million input tokens and $0.50 per million output tokens, making it well-suited for repetitive, structured function calling.

High-volume routing: Gemini 3.8 Flash and DeepSeek V4.1 Flash

When you need to balance cost and quality for medium-complexity tasks, vibiz/balanced (Google's Gemini 3.8 Flash) offers a middle tier at $0.825 per million input tokens and $4.125 per million output tokens. For high-volume log ingestion or processing vast inputs before invoking a tool, vibiz/lite (DeepSeek V4.1 Flash) provides a 1M context window at $0.14 per million input tokens. To evaluate cost trade-offs across model families, check which LLM is the best value for money in 2026?.

Calling agentic models through an OpenAI-compatible gateway

Switching models between agent steps usually requires importing separate SDKs and rewriting function-definition schemas. With thelastapi, you use a standard client pointed to VIBIZ_AI_BASE_URL.

When you run your project locally:

Terminal
vibiz dev

This writes the development environment, including VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY (with OPENAI_BASE_URL and OPENAI_API_KEY aliases), to .env.development.local.

You can define tools once using standard JSON schemas and execute calls against different providers:

TypeScript
import OpenAI from 'openai';

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

const tools: OpenAI.ChatCompletionTool[] = [
  {
    type: 'function',
    function: {
      name: 'get_account_status',
      description: 'Fetch the status of a project account',
      parameters: {
        type: 'object',
        properties: {
          projectId: { type: 'string' },
        },
        required: ['projectId'],
      },
    },
  },
];

// Execute a tool-calling request using Claude Sonnet 5.5
const response = await openai.chat.completions.create({
  model: 'vibiz/smart',
  messages: [{ role: 'user', content: 'Check account status for prj_123' }],
  tools,
});

console.log(response.choices[0]?.message.tool_calls);

You can also specify models by their exact lab identifier, such as anthropic/claude-sonnet-5.5 or moonshotai/kimi-k3.1-pro. Over 400 language models can be invoked this way. The gateway never swaps models behind your back: if a model is unavailable, the API returns model_unavailable or provider_unavailable with a retry hint. Every response includes served_model and cost_micro_usd so you can verify what ran and what it cost.

Giving your agent real execution tools over MCP

A model's tool-calling capability is only useful if it connects to working tools. Instead of writing custom API wrappers for hosting, databases, email, and payments, thelastapi exposes its capabilities via the Model Context Protocol (MCP).

You can connect Claude Code, Codex, or Cursor to the remote MCP server at https://thelastapi.dev/mcp:

Terminal
claude mcp add --transport http vibiz https://thelastapi.dev/mcp

Or connect the local MCP server through the CLI:

Terminal
claude mcp add vibiz -- npx -y @vibiz/cli mcp

This grants your agent access to standard tools:

  • vibiz_docs: Reads guides and specifications before calling tools.
  • vibiz_database: Runs read-only queries or inspects development database tables.
  • vibiz_send_email: Sends outbound email.
  • vibiz_run_action: Scrapes web pages, runs web searches, crawls sites, or extracts public competitor ads.
  • vibiz_deploy: Deploys local folders or passes raw files to hosting.
  • vibiz_payments: Creates products, prices, and checkout links.

To learn more about connecting your workflows, read what is MCP, and how do you give Claude Code real tools? and connect a remote MCP server to Claude, ChatGPT, Cursor and Codex. You can also install curated workflow instructions directly into Claude Code, Codex, or Cursor using agent skills by running vibiz skills add --global.

Securing tool use with scoped agent permissions

Letting an autonomous model execute tools creates operational risk. If an agent hallucinates, it should not have the ability to delete production databases, alter live domains, or issue unauthorized refunds.

thelastapi addresses this through key scoping in keys and environments:

  • Full-access key (access: owner): Held by owners, CI, or explicit CLI sessions. Can perform all operations, including reading production secrets and executing live refunds.
  • Limited key (access: agent): Intended for autonomous agents. A Limited key can create projects, run deploys, query the development database branch, use AI, and run actions. It is blocked from reading production secrets, removing domains, or handling live money.

If an agent using a Limited key attempts an operation requiring owner permissions, the API responds with 403 owner_only:

JSON
{
  "error": "forbidden",
  "details": {
    "reason": "owner_only",
    "permission": "payments.live:write",
    "grant_url": "https://thelastapi.dev/keys/key_123/allow?permission=payments.live:write",
    "console_url": "https://thelastapi.dev/console",
    "next_step": "Allow the permission at grant_url or complete the action in the console."
  }
}

The agent can display grant_url to you so you can approve just that single capability without exposing full access or sharing production credentials.

Managing spend, token limits, and per-call costs

Agent loops can consume tokens rapidly when retrying failed tools or processing verbose outputs. thelastapi includes several safeguards described in the agents and CLI documentation:

  1. Token caps: max_tokens defaults to 1,024 when omitted, with a maximum limit of 16,384 tokens per request.
  2. Rate limits: Account keys are set to 300 requests and 400,000 tokens per minute. Project keys receive 120 requests and 200,000 tokens per minute.
  3. Spend ceilings: An account-wide daily ceiling defaults to $5 per day (configurable by the owner), while each project has a default daily budget of $1.

You can inspect what your agent spent across different models or tools using the CLI:

Terminal
vibiz usage --period 24h --by model
vibiz usage --period 7d --by tool

To adjust a project's daily AI allowance:

Terminal
vibiz ai budget 5 --project prj_123

You can review the entire setup in one API key for an AI agent: hosting, database, email, payments and models.

To get started with agent tooling, install the CLI or follow the instructions in the quickstart. If you need an account, create one at thelastapi.dev/start.

Frequently asked questions

Which model should I use for tool calling if I want to minimize API costs?

For low-cost tool calling, `vibiz/fast` (OpenAI's GPT-6 Luna) costs $0.10 per million input tokens and $0.50 per million output tokens, while `vibiz/lite` (DeepSeek V4.1 Flash) costs $0.14 per million input tokens and $0.42 per million output tokens. Both handle high-frequency structured function execution efficiently.

Can an agent swap models during a multi-turn conversation?

Yes. Because the `/v1/ai` endpoint uses the standard OpenAI chat completions format, your application can route complex planning steps to `vibiz/smart` (Claude Sonnet 5.5) and pass routine tool responses or JSON extraction to `vibiz/fast` using the same client configuration.

What happens if an agent tries to call a tool or API endpoint that is outside its permissions?

When an agent uses a Limited key, any restricted action returns a `403 forbidden` error with `details.reason: "owner_only"`. The response provides a `grant_url` link that the agent presents to the human owner to selectively grant that specific permission.

How can I view the exact cost of each tool call made by a model?

Every chat completion response returned by the thelastapi gateway includes a `cost_micro_usd` field alongside `served_model`. You can also check aggregated spend by running `vibiz usage --by model` or `vibiz usage --by tool` in the CLI.