How mquan/api2ai works
Main Components
a) Core Engine Components:
• OpenAPI Specification Parser
• AI Integration Layer
• Authentication Handler
• Operation Selector
• Request Executor
b) Server Components:
• Next.js API Server
• Configuration Manager
• API Endpoints
c) External Dependencies:
• OpenAI API
• User-provided APIs
• OpenAPI Specifications
[Client Layer]
[API Server Layer]
[Core Processing Layer]
[External Services Layer]
Component Relationships
a) Input Flow:
• User Request → Next.js API Server
• API Server → Core Engine
• Core Engine → OpenAI API
• Core Engine → Target APIs
b) Processing Flow:
• OpenAPI Specs → OAS Loader
• User Prompt → AI Agent
• AI Agent → Operation Selector
• Operation Selector → Request Executor
Specific Implementation Details
[Client Request]
• ↓
[Next.js API Server (server/pages/api)]
• ↓
[ApiAgent (core/src/ai/api-agent.ts)]
• [OAS Loader (core/src/api/oas-loader.ts)]
• [Operation Selector (core/src/ai/tools/select-operation.ts)]
• [Argument Parser (core/src/ai/tools/parse-arguments.ts)]
• [Security Handler (core/src/api/security.ts)]
• ↓
[External APIs]
Important Notes
• Modular nature of the system, emphasizing how multiple APIs can be configured
• Authentication flow for different security schemes (Bearer, API Key, Basic Auth)
• Demonstrate how the AI agent interfaces with both the OpenAPI specs and the target APIs
• Configuration flow from api2ai.config.ts
Technical Details
• Support for OpenAPI Spec 3.0.0+
• Integration with GPT models (3.5-turbo-1106, gpt-4-1106-preview)
• Authentication schemes supported
• Request/Response flow