aw_agents.adapters.openapi

OpenAPI/FastAPI adapter for AW agents.

This adapter wraps any AgentBase subclass to expose it as a REST API with OpenAPI spec for use with ChatGPT Custom GPTs.

Functions

create_api_server_script(agent_class, ...[, ...])

Generate an API server script for an agent.

Classes

OpenAPIAdapter(agent, *[, title, ...])

Adapter to expose an AgentBase as a FastAPI/OpenAPI service.

class aw_agents.adapters.openapi.OpenAPIAdapter(agent, *, title='AI Agent API', description='AI Agent exposed via OpenAPI', version='1.0.0', server_url=None)[source]

Bases: object

Adapter to expose an AgentBase as a FastAPI/OpenAPI service.

Usage:

agent = YourAgent()
adapter = OpenAPIAdapter(agent, title="Your Agent API")
adapter.run(port=8000)
run(host='0.0.0.0', port=8000, **kwargs)[source]

Run the FastAPI server.

Parameters:
  • host (str) – Host to bind to

  • port (int) – Port to bind to

  • **kwargs – Additional uvicorn arguments

aw_agents.adapters.openapi.create_api_server_script(agent_class, output_path, *, default_port=8000)[source]

Generate an API server script for an agent.

Parameters:
  • agent_class – Agent class to wrap

  • output_path (Path) – Path to write the script

  • default_port (int) – Default port for the server