# AI integrations in Python

Expose Python services as tools for AI agents and call Claude, OpenAI, Gemini or self-hosted models from your own code.

## Get started

Expose a service as an MCP tool and call it from an AI agent, end to end.

[MCP tutorial](https://zato.io/tutorials/mcp/01.html)

```yaml
name: MCP gateways
actors:
  - id: agent
    label: AI agent
  - id: gateway
    label: MCP gateway
  - id: service
    label: Python service
steps:
  - from: agent
    to: gateway
    label: The agent calls a tool
    align: left
    items:
      - Authentication comes first
      - Arguments are validated
      - Rate limits apply
  - from: gateway
    to: service
    label: The gateway invokes the service
  - from: service
    to: gateway
    kind: return
    label: The service returns its response
  - from: gateway
    to: agent
    kind: return
    label: The agent receives the shaped response
    align: left
    items:
      - Responses are shaped and PII is removed
      - Sizes are capped in tokens
      - The audit log records the exchange
```

```yaml
name: Integrating with LLMs
actors:
  - id: service
    label: Python service
  - id: connection
    label: LLM connection
  - id: provider
    label: LLM provider
steps:
  - from: service
    to: connection
    label: The service calls the model
    align: left
    items:
      - Credentials are managed by the platform
      - Skills form the system context
      - Chat history is trimmed to fit
  - from: connection
    to: provider
    label: The connection sends the request
  - from: provider
    to: connection
    kind: return
    label: The provider returns the completion
  - from: connection
    to: service
    kind: return
    label: The service receives the completion
    align: left
    items:
      - Token usage comes back with the response
      - The audit log records the call
```

## Expose your systems to agents

[Tool exposure Publish each assigned service as one MCP tool with a schema derived from its input and output.](https://zato.io/docs/ai/mcp/tool-schemas.html) [Prompts Serve a gateway's skills to agents as MCP prompts.](https://zato.io/docs/ai/mcp/prompts.html) [Sharing with clients Give the teams that configure AI agents a gateway's details as one document.](https://zato.io/docs/ai/mcp/sharing-with-clients.html)

## Call models from your code

[LLM invoke Call a model from a Python service and get token usage with each response.](https://zato.io/docs/ai/llm/invoke.html) [Chat Hold multi-turn conversations with managed history.](https://zato.io/docs/ai/llm/chat.html) [Skills Reuse instructions as LLM system context and as MCP prompts.](https://zato.io/docs/ai/skills/index.html)

## Protect data and access

[Security Require authentication on every gateway with API keys, Basic Auth or bearer tokens.](https://zato.io/docs/ai/mcp/security.html) [PII removal Replace personally identifiable information before a response reaches a model.](https://zato.io/docs/ai/mcp/response-controls.html#pii-removal) [Rate limits Cap each agent's traffic through its security definition.](https://zato.io/docs/ai/mcp/rate-limits.html)

## Shape and audit traffic

[Response shaping Remove nulls, extra whitespace and base64 data, neutralize hostile content and cap sizes in tokens.](https://zato.io/docs/ai/mcp/response-controls.html) [Argument validation Refuse invalid tool calls before any service code runs.](https://zato.io/docs/ai/mcp/argument-validation.html) [Audit log Record the caller, tool, outcome and sizes of each agent request.](https://zato.io/docs/ai/mcp/audit-log.html)

## Operate the AI layer

[GitOps Keep the whole AI configuration as enmasse YAML in version control.](https://zato.io/docs/ai/enmasse.html) [Export Export each gateway as a registry-format server.json.](https://zato.io/docs/ai/mcp/sharing-with-clients.html)

## More resources

[Cost and limits Cap cost and traffic with token limits, timeouts and size caps.](https://zato.io/docs/ai/cost-and-limits.html)
