# Google Adk Openapi Tool

> Create ADK tools from OpenAPI specs. Use when connecting agents to REST APIs defined by OpenAPI/Swagger specs — auto-generates tools from endpoints with auth support.

- Skill: `eagleisbatman/google-adk-openapi-tool` (Agent Skill)
- Install (CLI): `npx skillmds@latest add eagleisbatman/google-adk-openapi-tool`
- Raw SKILL.md: https://api.skillmd.com/api/skills/eagleisbatman/google-adk-openapi-tool/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: eagleisbatman (https://skillmd.com/u/eagleisbatman)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/eagleisbatman/google-adk-openapi-tool

---


# Google ADK — OpenAPI Tool Integration

## Import

```python
from google.adk.tools.openapi_tool.openapi_toolset import OpenAPIToolset
```

## Basic Usage (from spec file)

```python
from google.adk.agents import Agent
from google.adk.tools.openapi_tool.openapi_toolset import OpenAPIToolset

toolset = OpenAPIToolset(
    spec_str=open("openapi.yaml").read(),
    spec_str_type="yaml",  # or "json"
)

root_agent = Agent(
    name="api_agent",
    model="gemini-2.5-flash",
    instruction="Use the API to help users manage their resources.",
    tools=[toolset],
)
```

## From JSON Spec

```python
import json

with open("api_spec.json") as f:
    spec = json.dumps(json.load(f))

toolset = OpenAPIToolset(
    spec_str=spec,
    spec_str_type="json",
)
```

## With Authentication (API Key)

```python
from google.adk.tools.openapi_tool.openapi_toolset import OpenAPIToolset
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes

api_key_credential = AuthCredential(
    auth_type=AuthCredentialTypes.API_KEY,
    api_key="your-api-key",
)

toolset = OpenAPIToolset(
    spec_str=open("spec.yaml").read(),
    spec_str_type="yaml",
    auth_credential=api_key_credential,
)
```

## With Bearer Token Auth

```python
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes, HttpAuth, HttpCredentials

bearer_credential = AuthCredential(
    auth_type=AuthCredentialTypes.HTTP,
    http=HttpAuth(
        scheme="bearer",
        credentials=HttpCredentials(token="your-bearer-token"),
    ),
)

toolset = OpenAPIToolset(
    spec_str=open("spec.yaml").read(),
    spec_str_type="yaml",
    auth_credential=bearer_credential,
)
```

## Tool Filtering

```python
toolset = OpenAPIToolset(
    spec_str=open("spec.yaml").read(),
    spec_str_type="yaml",
    tool_filter=["getUsers", "createUser", "deleteUser"],
)
```

## OpenAPIToolset Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `spec_str` | str | OpenAPI spec content as string |
| `spec_str_type` | str | `"yaml"` or `"json"` |
| `auth_credential` | AuthCredential | Authentication credentials |
| `tool_filter` | list[str] | Operation IDs to include |

## How It Works

1. Parses the OpenAPI spec
2. Creates one tool per operation (operationId becomes tool name)
3. Parameters/request body become tool parameters
4. Tool descriptions come from operation `summary` and `description`
5. Authentication is applied to all requests

## OpenAPI Spec Requirements

- Must have `operationId` for each endpoint (becomes the tool function name)
- Parameters need `description` fields (becomes tool parameter descriptions)
- Request body schemas define the tool's input structure

## Example Spec (Minimal)

```yaml
openapi: "3.0.0"
info:
  title: "Task API"
  version: "1.0.0"
servers:
  - url: "https://api.example.com/v1"
paths:
  /tasks:
    get:
      operationId: listTasks
      summary: "List all tasks"
      responses:
        "200":
          description: "List of tasks"
    post:
      operationId: createTask
      summary: "Create a new task"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  description: "Task title"
                priority:
                  type: string
                  enum: [low, medium, high]
                  description: "Task priority level"
```

## Key Rules

- Each operation in the spec becomes a separate tool
- `operationId` is required and becomes the tool name the LLM sees
- Tool descriptions come from `summary` + `description` fields
- Keep spec descriptions clear and actionable for the LLM
- Filter tools to only expose what the agent needs
- Authentication is applied globally to all tools from the same spec

## Related Skills

- `google-adk-auth` — Authentication credentials, schemes, and credential services
- `google-adk-function-tool` — Custom function tools
- `google-adk-mcp-tool` — MCP server integration

