Skip to content

The API-as-Agent system transforms the traditional API interaction model by providing an intelligent natural language interface.

License

Notifications You must be signed in to change notification settings

harsha-iiiv/api-as-agent

Repository files navigation

API-as-Agent (5*A) - AI-Powered API Interface

A Streamlit application that transforms OpenAPI specifications into intelligent AI agents capable of understanding natural language queries and executing API calls automatically.

🌟 Features

Core Capabilities

  • Natural Language API Interaction: Ask APIs questions in plain English instead of reading documentation 1
  • Automatic Endpoint Discovery: AI agent analyzes OpenAPI specs and finds the right endpoints for your queries 2
  • Authentication Handling: Automatic detection and configuration of API authentication schemes 3
  • Request Parameter Generation: Auto-fills API parameters based on natural language understanding 4

Multi-API Coordination Patterns

The application supports three coordination patterns for handling multiple APIs simultaneously:

  1. Coordinator Pattern: Central control evaluates all APIs and selects the best match 5
  2. Mesh Pattern: Primary API with peer consultation for complex queries 6
  3. Service Discovery Pattern: Directory-based API selection 7

User Interface Features

  • Interactive Forms: Dynamic form generation for API parameters 8
  • Request History: Track and review previous API interactions 9
  • cURL Export: Generate cURL commands for API requests 10
  • Real-time Authentication Status: Monitor API authentication configuration 11

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Google Gemini API key
  • OpenAPI 3.0 specification files (YAML or JSON)

Installation

  1. Clone the repository
  2. Install dependencies (requirements need to be documented)
  3. Set up environment variables:
    GEMINI_API_KEY=your_gemini_api_key_here
    

Configuration

The application uses Google Gemini for natural language processing 12 . Configure your API key either in a .env file or Streamlit secrets 13 .

Running the Application

streamlit run app.py

📖 Usage

  1. Upload OpenAPI Specs: Use the sidebar to upload one or more OpenAPI 3.0 specification files 14
  2. Select Active API: Choose which API to interact with 15
  3. Choose Coordination Pattern: For multiple APIs, select how they should coordinate 16
  4. Ask Natural Language Questions: Type your request in plain English 17
  5. Review and Execute: The AI will suggest an API call which you can review and execute 18

🏗️ Architecture

Core Components

  • Main Application: Streamlit-based user interface and workflow orchestration 19
  • Gemini Agent: Natural language processing and endpoint matching 20
  • Coordination Engine: Multi-API pattern implementations 21
  • OpenAPI Utils: Specification parsing and validation 22
  • Authentication Module: Security scheme handling 3

Configuration Parameters

  • Maximum history entries: 10 23
  • Gemini model: gemini-1.5-flash 24
  • Request timeout: 30 seconds 25
  • Confidence thresholds for coordination patterns 26

📁 Project Structure

api-as-agent/
├── app.py                 # Main Streamlit application
├── config.py             # Configuration and constants
├── gemini_agent.py       # AI agent implementation
├── coordination.py       # Multi-API coordination patterns
├── openapi_utils.py      # OpenAPI specification utilities
├── auth.py              # Authentication handling
├── api_request.py       # API request execution
├── ui_components.py     # UI component functions
├── utils.py             # General utilities
├── .devcontainer/       # Development container configuration
└── LICENSE             # License file

🤝 Contributing

This project implements the API-as-an-AI-Agent (5*A) concept and still under the development.

About

The API-as-Agent system transforms the traditional API interaction model by providing an intelligent natural language interface.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages