Use OpenAPI specifications to define your plugin's API without writing manual definitions.
- Overview
- SperaxOS Plugin Compatibility
- OpenAPI Specification
- Creating an OpenAPI Spec
- Manifest Configuration
- OpenAPI Requirements
- Integrating OpenAPI with SperaxOS
- Examples
- Converting Existing APIs
- Troubleshooting
OpenAPI (formerly Swagger) is a standard for describing RESTful APIs. The plugin system can read your OpenAPI spec and automatically create Function Call definitions.
SperaxOS's plugin mechanism supports the OpenAPI specification, which is a standard for defining and describing RESTful APIs. By using OpenAPI, developers can create a clear, language-agnostic API description to facilitate the correct implementation and usage of the API.
- ✅ Use existing API documentation
- ✅ Auto-generate function definitions
- ✅ Standard tooling support
- ✅ Easy to maintain
- ✅ Compatible with OpenAI ChatGPT plugins
- ✅ Language-agnostic API descriptions
- ✅ Clear documentation for endpoints, parameters, and responses
- You provide an OpenAPI spec URL in your manifest
- The system reads the spec
- Each operation becomes a callable function
- Parameters are extracted from the spec
- AI can call any operation
- SwaggerClient interacts with third-party services defined in the spec
SperaxOS's plugin system is fully compatible with OpenAPI documents. When you create a SperaxOS plugin, you only need to follow these steps to convert an OpenAPI service into a conversation plugin:
Develop your service API, ensuring that it can handle requests from SperaxOS and return appropriate responses.
Example API Server:
// api/weather.ts
export default async (req: Request) => {
const { city } = await req.json();
// Fetch weather data
const weather = await fetchWeatherData(city);
return new Response(JSON.stringify({
temperature: weather.temp,
condition: weather.condition,
humidity: weather.humidity
}), {
headers: { 'Content-Type': 'application/json' }
});
};Use the OpenAPI specification (in YAML or JSON format) to describe your API. This document should provide detailed information about:
- Endpoints
- Parameters
- Response formats
- Authentication methods
- Error codes
Example OpenAPI Document:
openapi: 3.0.0
info:
title: Weather API
description: Get current weather data for any city
version: 1.0.0
servers:
- url: https://api.weather.example.com
description: Production server
paths:
/weather/current:
post:
operationId: getCurrentWeather
summary: Get current weather for a city
description: Returns temperature, condition, and humidity for the specified city
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- city
properties:
city:
type: string
description: City name (e.g., "Tokyo", "New York")
example: "Tokyo"
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
temperature:
type: number
description: Temperature in Celsius
condition:
type: string
description: Weather condition (e.g., "sunny", "cloudy")
humidity:
type: number
description: Humidity percentage
'400':
description: Invalid city name
'500':
description: Server errorCreate a manifest.json plugin manifest file for SperaxOS, which includes the plugin's metadata and, most importantly, fill in the URL of your OpenAPI document in the openapi field:
{
"identifier": "weather-plugin",
"openapi": "https://api.weather.example.com/openapi.json",
"meta": {
"avatar": "🌤️",
"title": "Weather Plugin",
"description": "Get real-time weather data for any city worldwide",
"tags": ["weather", "data", "api"]
},
"homepage": "https://weather.example.com",
"settings": {
"type": "object",
"properties": {
"apiKey": {
"type": "string",
"title": "API Key",
"description": "Your Weather API key",
"format": "password"
}
},
"required": ["apiKey"]
}
}The OpenAPI specification is a standard for describing the structure and behavior of RESTful APIs. This specification allows developers to define:
-
Basic Information
- API title, description, and version
- Contact information
- License details
-
Server Information
- URL of the API server
- Multiple environments (production, staging)
- Server variables
-
Endpoints and Operations
- Available endpoints (paths)
- HTTP methods (GET, POST, PUT, DELETE, etc.)
- Operation IDs for function calling
-
Parameters
- Input parameters for each operation
- Path, query, header, and cookie parameters
- Request body schemas
-
Responses
- Expected responses for each operation
- Success and error response formats
- HTTP status codes
-
Authentication Methods
- No authentication
- HTTP basic authentication
- Bearer token (JWT)
- OAuth2
- API keys
-
Data Models
- Reusable schemas
- Component definitions
- Common response messages and error codes
You can view a complete example of an OpenAPI document here: CoinGecko OpenAPI Spec
For a detailed introduction to OpenAPI, refer to the OpenAPI Specification.
openapi: 3.0.0
info:
title: Weather API
version: 1.0.0
servers:
- url: https://api.weather.example.com
paths:
/current:
post:
operationId: getCurrentWeather
summary: Get current weather for a city
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- city
properties:
city:
type: string
description: City name
responses:
'200':
description: Weather data
content:
application/json:
schema:
type: object
properties:
temperature:
type: number
condition:
type: string{
"openapi": "3.0.0",
"info": {
"title": "Weather API",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.weather.example.com"
}
],
"paths": {
"/current": {
"post": {
"operationId": "getCurrentWeather",
"summary": "Get current weather for a city",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["city"],
"properties": {
"city": {
"type": "string",
"description": "City name"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Weather data"
}
}
}
}
}
}{
"identifier": "weather-plugin",
"openapi": "https://api.example.com/openapi.json",
"meta": {
"avatar": "🌤️",
"title": "Weather Plugin",
"description": "Get weather data"
}
}You can combine OpenAPI with manual API definitions:
{
"identifier": "my-plugin",
"openapi": "https://api.example.com/openapi.json",
"api": [
{
"url": "https://api.example.com/custom",
"name": "customEndpoint",
"description": "A custom endpoint not in OpenAPI",
"parameters": {
"type": "object",
"properties": {
"param": { "type": "string" }
}
}
}
]
}| Field | Description |
|---|---|
openapi |
Version (3.0.0 or 3.1.0) |
info.title |
API title |
info.version |
API version |
servers |
At least one server URL |
paths |
At least one path/operation |
Each operation should have:
| Field | Required | Description |
|---|---|---|
operationId |
Yes | Unique function name |
summary or description |
Yes | What the function does |
requestBody or parameters |
Recommended | Input parameters |
responses |
Yes | Expected responses |
paths:
/search:
post:
operationId: search
requestBody:
content:
application/json:
schema:
type: object
properties:
query:
type: string
filters:
type: objectproperties:
city:
type: string
description: "The city name to get weather for (e.g., 'New York', 'London')"properties:
unit:
type: string
enum: ["celsius", "fahrenheit"]
description: "Temperature unit"{
"openapi": "3.0.0",
"info": {
"title": "Crypto Prices API",
"version": "1.0.0"
},
"servers": [
{ "url": "https://api.coingecko.com/api/v3" }
],
"paths": {
"/simple/price": {
"get": {
"operationId": "getPrice",
"summary": "Get current price of cryptocurrencies",
"parameters": [
{
"name": "ids",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "Comma-separated coin IDs (e.g., 'bitcoin,ethereum')"
},
{
"name": "vs_currencies",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "Comma-separated currencies (e.g., 'usd,eur')"
}
],
"responses": {
"200": {
"description": "Price data"
}
}
}
},
"/coins/{id}": {
"get": {
"operationId": "getCoinDetails",
"summary": "Get detailed info about a coin",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": { "type": "string" },
"description": "Coin ID (e.g., 'bitcoin')"
}
],
"responses": {
"200": {
"description": "Coin details"
}
}
}
}
}
}openapi: 3.0.0
info:
title: Search API
version: 1.0.0
servers:
- url: https://search.example.com
paths:
/search:
post:
operationId: search
summary: Search with advanced filters
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- query
properties:
query:
type: string
description: Search query
filters:
type: object
properties:
category:
type: string
enum: ["news", "images", "videos"]
dateRange:
type: string
enum: ["day", "week", "month", "year"]
language:
type: string
limit:
type: integer
minimum: 1
maximum: 100
default: 10
responses:
'200':
description: Search resultsUse the swagger2openapi tool:
npx swagger2openapi swagger.json -o openapi.json- Export collection as JSON
- Use postman-to-openapi:
npx postman-to-openapi collection.json -o openapi.jsonMap your endpoints to OpenAPI:
| Your API | OpenAPI |
|---|---|
| GET /users?id=123 | GET with query parameter |
| POST /users body: {} | POST with requestBody |
| PUT /users/123 | PUT with path parameter |
| Headers | parameters with in: header |
Problem: OpenAPI spec missing servers array
Solution: Add servers:
{
"servers": [
{ "url": "https://api.example.com" }
]
}Problem: Operations without operationId
Solution: Add unique operationId to each operation:
paths:
/endpoint:
post:
operationId: uniqueFunctionName # Add thisProblem: Parameters not being passed to function
Solution: Ensure proper schema structure:
requestBody:
content:
application/json:
schema:
type: object # Must be object
properties:
param:
type: string
description: "Add descriptions!" # Helps AI understandProblem: Using localhost in production
Solution: Use environment-specific servers:
servers:
- url: https://api.example.com
description: Production
- url: http://localhost:3000
description: DevelopmentProblem: Browser blocks cross-origin requests
Solution: Ensure your server returns proper CORS headers:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
- Plugin Manifest Reference - Full manifest docs
- Gateway Guide - Set up local development
- Quick Start - Build your first plugin
Once your API and plugin manifest file are ready, you can integrate them with SperaxOS.
- User Installation: In the SperaxOS UI, users can install your plugin from the plugin marketplace
- Manifest Loading: SperaxOS reads your plugin manifest and fetches the OpenAPI document
- Schema Parsing: The system parses endpoints defined in the OpenAPI document
- Function Registration: Each operation becomes available as a function call
- User Interaction: Users interact with your service through the AI assistant
- API Communication: The OpenAPI document guides SperaxOS on how to communicate with your API
The CoinGecko plugin demonstrates OpenAPI integration. Users can query cryptocurrency prices, and SperaxOS uses the OpenAPI spec to correctly format requests and interpret responses.
Provide detailed descriptions for all operations and parameters. The AI uses these to understand when to call your API.
Always provide unique operationId values - these become the function names:
paths:
/weather:
get:
operationId: getCurrentWeather # Clear function nameInclude success and error responses with appropriate HTTP status codes.
Use semantic versioning in your OpenAPI spec info section.
Validate your OpenAPI spec using tools like Swagger Editor before deployment.
- OpenAPI Specification: https://swagger.io/specification/
- Swagger Editor: https://editor.swagger.io/
- OpenAPI Generator: https://openapi-generator.tech/
- Plugin Manifest Reference: See PLUGIN_MANIFEST.md
By following the OpenAPI specification, you ensure accurate API documentation and seamless integration with SperaxOS, providing users with a rich, reliable plugin experience.