Mirra
Mirra APIResources

Resources Overview

Resources are installable API endpoints, LLM integrations, and third-party service connections that scripts and templates can invoke. Resources provide standardized access to external services through OpenAPI 3.0 specifications, enabling type-safe integration with authentication, rate limiting, and usage tracking.

What are Resources?

Resources provide the foundation for external service integration within Mirra. Each resource encapsulates an API endpoint, authentication mechanism, and method definitions in a standardized format that Scripts and Templates can invoke.

All resources require a valid OpenAPI 3.0 specification, which the platform uses for automatic documentation generation, request/response validation, and SDK client generation. This specification-driven approach ensures type safety and clear contracts between resource providers and consumers.

Syntax

Creating a Resource

POST /api/sdk/v1/resources

Resource Structure

{
  "name": "Resource Name",
  "description": "Resource description",
  "resourceType": "api | llm | script | integration",
  "openApiSpec": { /* OpenAPI 3.0 specification */ },
  "endpoint": { /* Endpoint configuration */ },
  "pricing": { /* Pricing model */ }
}

Resource Types

Mirra supports four resource types, each optimized for specific integration patterns.

API

api

Standard HTTP APIs with defined methods, authentication, and request/response schemas. API resources expose RESTful endpoints for data retrieval, manipulation, and service integration.

{
  "resourceType": "api",
  "endpoint": {
    "baseUrl": "https://api.example.com",
    "authentication": "api_key",
    "methods": [
      {
        "name": "getData",
        "httpMethod": "GET",
        "path": "/v1/data"
      }
    ]
  }
}

LLM

llm

Large Language Model endpoints for chat completion, text generation, and AI-powered processing. LLM resources provide standardized access to language models with token counting and cost tracking.

{
  "resourceType": "llm",
  "endpoint": {
    "baseUrl": "https://api.openai.com/v1",
    "authentication": "bearer",
    "methods": [
      {
        "name": "chatCompletion",
        "httpMethod": "POST",
        "path": "/chat/completions"
      }
    ]
  }
}

LLM resources are treated as standard API endpoints. To create a chat UI with subdomain deployment, bundle your LLM resource in a Template.

Script

script

Serverless functions deployed to the Mirra platform that can be invoked as resources. Script resources enable custom logic and data processing within the Mirra ecosystem.

{
  "resourceType": "script",
  "endpoint": {
    "baseUrl": "https://api.getmirra.app/scripts/your-function",
    "authentication": "none"
  }
}

Integration

integration

Third-party service integrations with OAuth 2.0 or complex authentication flows. Integration resources handle token management, refresh logic, and service-specific authentication patterns.

{
  "resourceType": "integration",
  "endpoint": {
    "baseUrl": "https://api.service.com",
    "authentication": "oauth2",
    "authConfig": {
      "authUrl": "https://oauth.service.com/authorize",
      "tokenUrl": "https://oauth.service.com/token",
      "scopes": ["read", "write"]
    }
  }
}

When to Use Resources

Resources are ideal for:

  • External API Integration - Wrap third-party APIs for use in scripts and templates
  • LLM Access - Provide standardized access to language models with cost tracking
  • Marketplace Distribution - Publish and monetize API integrations
  • Service Abstraction - Hide authentication complexity from script developers
  • Rate Limiting - Control API usage and prevent abuse

Resources abstract away the complexity of authentication, error handling, and API-specific quirks, allowing script developers to focus on business logic.


Key Concepts

OpenAPI 3.0 Specification

Every resource must include a complete OpenAPI 3.0 specification defining all endpoints, parameters, request bodies, and response schemas. The platform uses this specification for:

  • Auto-generated documentation - Interactive API documentation for resource consumers
  • Type safety - Request and response validation against defined schemas
  • SDK generation - Automatic client library generation for multiple languages
  • Clear contracts - Explicit interface definitions between providers and consumers

Method Definitions

Each resource method defines an HTTP operation with parameters, request body schema, response schema, and optional cost tracking. Methods support all standard HTTP verbs and include path parameters using curly brace syntax: /users/{userId}.

Authentication

Resources support five authentication mechanisms: none, api_key, bearer, basic, and oauth2. Each method is configured through the authentication field and optional authConfig object. The platform handles credential storage and injection automatically.

Rate Limiting

Resources can define rate limits to control usage and prevent abuse. Rate limits specify the maximum number of requests allowed within a time window (1m, 1h, 1d). When exceeded, the platform returns a 429 Too Many Requests response.


Next Steps

  • Endpoints - Complete API reference for all resource operations
  • Examples - Practical examples for creating and using resources
  • Technical Notes - Advanced configuration, authentication, and troubleshooting

See Also

  • Scripts - Build serverless functions that invoke resources
  • Templates - Bundle resources with pages and scripts
  • Authentication - API authentication and authorization

On this page