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
Resource Structure
Resource Types
Mirra supports four resource types, each optimized for specific integration patterns.
API
apiStandard HTTP APIs with defined methods, authentication, and request/response schemas. API resources expose RESTful endpoints for data retrieval, manipulation, and service integration.
LLM
llmLarge 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.
LLM resources are treated as standard API endpoints. To create a chat UI with subdomain deployment, bundle your LLM resource in a Template.
Script
scriptServerless functions deployed to the Mirra platform that can be invoked as resources. Script resources enable custom logic and data processing within the Mirra ecosystem.
Integration
integrationThird-party service integrations with OAuth 2.0 or complex authentication flows. Integration resources handle token management, refresh logic, and service-specific authentication patterns.
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