Get Started in 5 Minutes

In 5 minutes you'll connect an AI model to a real API and watch it call your tool.

Prefer a full working example? See the Python quickstart on GitHub.


What You'll Do

  1. Create a TengineAI project and generate an API key
  2. Register a tool that connects to a real API
  3. Run a Python script that calls the model
  4. Watch the model invoke your tool and return real data

Time to complete: ~5 minutes

You'll end up with an AI model calling a real API through TengineAI.


Prerequisites

  • Python 3.8+ and pip
  • An Anthropic API key
  • A TengineAI account (you can create one in Step 1)

How This Works

Claude
  ↓
Tool Request
  ↓
TengineAI
  ↓
JSONPlaceholder API

The model requests a tool. TengineAI executes the API call and returns the result.


Step 1: Create a Project and Generate an API Key

  1. Go to your TengineAI Dashboard and create an account if needed
  2. Create a new project
  3. Open your project → Integrations tab
  4. Click New Integration, give it a name (e.g. Dev Test)
  5. Click Setup Integration to create it (this generates the API key)
  6. Copy the API Key — it starts with tengine_ and is shown only once

Step 2: Register a Tool (Console UI)

This example uses JSONPlaceholder — a free public API that returns structured JSON.

From the project you set up in Step 1:

  1. Click the Tools tab in the project navigation.
  2. Click Create Tool.

You are creating a tool that fetches a post by ID from JSONPlaceholder.

Fill in the fields as follows:

Basic Information

  • Tool name: jsonplaceholder-get-post
  • Scope - Requires member context: Off (leave disabled for this quick start)
  • Description: Fetch a post by ID from JSONPlaceholder

Request

  • Base URL (Pinned Origin): https://jsonplaceholder.typicode.com
  • HTTP Method: GET
  • Endpoint Path: /posts/{post_id}
  • Headers (Optional): Leave empty ({})
  • Query Parameters (Optional): Leave empty ({})

{post_id} is a dynamic parameter. The model will supply this value when it calls the tool.

Authentication Strategy

  • Auth Strategy: None

Advanced — Input schema (copy-paste)

Expand the Advanced section, click JSON Editor, and paste the following as-is.

{
  "type": "object",
  "properties": {
    "post_id": {
      "type": "string",
      "description": "The post ID to fetch (1-100)."
    }
  },
  "required": ["post_id"]
}

Click Create Tool, then confirm the tool appears as enabled in your project's tool list.


Step 3: Run the Model

Install the SDK, create run.py, set your API keys, and run the script.

Install the SDK

pip install anthropic

Create run.py

import json
import os
import anthropic

client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

response = client.beta.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": "Fetch post 5 and summarize what it's about.",
        }
    ],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://app.tengine.ai/mcp/",
            "name": "tengineai",
            "authorization_token": os.environ["TENGINEAI_API_KEY"],
        }
    ],
    betas=["mcp-client-2025-04-04"],
)

for block in response.content:
    if block.type == "text":
        print(block.text)
    elif block.type == "mcp_tool_use":
        print(
            f"[tool_use] server={block.server_name} tool={block.name} id={block.id} "
            f"input={json.dumps(block.input, default=str)}"
        )
    elif block.type == "mcp_tool_result":
        print(
            f"[tool_result] id={block.tool_use_id} is_error={getattr(block, 'is_error', False)}"
        )
        print(block.content)

Set your API keys

export ANTHROPIC_API_KEY="sk-ant-..."
export TENGINEAI_API_KEY="tengine_..."

Run the script

python run.py

Example Output

Claude:

"Post #5 discusses themes of rejection and devotion written by user 1."

Claude used your tool to fetch the real API response and summarize it.


What Just Happened?

You just wired a public HTTP API into a model with a few fields in a UI form. Here's the full execution chain:

  1. Tool registration — You created a custom tool in the TengineAI Console (base URL, method, path template, input schema).
  2. Tool discovery — The Anthropic SDK fetched your project's tool list from TengineAI. The model saw jsonplaceholder-get-post in its available tools.
  3. Tool selection — Claude analyzed the prompt ("Fetch post 5") and decided to call your tool with {"post_id": "5"}.
  4. Request rendered — TengineAI substituted {post_id} in the path, producing GET /posts/5.
  5. Identity injected — TengineAI added X-Tengine-Project-Id, X-Tengine-Request-Id, and X-Tengine-Timestamp to the outbound request.
  6. API called — TengineAI sent GET https://jsonplaceholder.typicode.com/posts/5 and received real JSON.
  7. Result returned — The JSON response was passed back to the model as tool output.
  8. Model responded — Claude synthesized the data into a natural language summary.

Your application code never made a direct API call. TengineAI handled the execution. You just described the tool.


What's the actual response from JSONPlaceholder?

{
  "userId": 1,
  "id": 5,
  "title": "nesciunt quas odio",
  "body": "repudiandae veniam quaerat sunt sed\nalias aut fugiat..."
}

Claude receives this, and produces something like:

"Post #5 is titled 'nesciunt quas odio' and discusses themes of rejection and evasion, written by user 1."

Real data. Real tool call. Your code defined the tool, TengineAI executed it.


Troubleshooting

401 UnauthorizedTENGINEAI_API_KEY is missing or invalid. Regenerate from the Integrations tab.

Tool not found / model says no tools — Confirm the tool is enabled in your project's Tools list, and your API key belongs to the same project.

403 Forbidden — member context required — You enabled "Requires member context" on the tool; either disable it for this quick start or use User-Scoped Sessions.


Success

✔ You just ran your first tool.

Claude discovered your tool, called it, and returned real data from an API.

The model requested a tool. TengineAI executed the API call and returned the result.

Next Steps

Now that you've seen the core loop — register tool → model calls it → real data returned: