Programmatic AI API
Generate applications programmatically
The ObjectQL AI Agent provides a programmatic API for generating and validating applications in your Node.js code.
Overview
The AI Agent is available in @objectql/core package and can be used to:
- Generate applications from natural language
- Validate metadata programmatically
- Build interactive application builders
- Create AI-powered development tools
Installation
The AI Agent is part of the core package:
Basic Usage
Creating an Agent
Generating Applications
Validating Metadata
Interactive Conversational Generation
Build applications through multi-turn conversation:
Refining Metadata
Iteratively improve metadata based on feedback:
TypeScript Types
AgentConfig
GenerateAppOptions
GenerateAppResult
ValidateMetadataOptions
ValidateMetadataResult
ConversationMessage
ConversationalGenerateOptions
ConversationalGenerateResult
Advanced Examples
Building a Web UI for App Generation
Automated Testing of Generated Apps
CI/CD Integration
Custom Metadata Generator
Error Handling
Always handle errors when using the AI Agent:
Best Practices
-
API Key Security: Never hardcode API keys. Use environment variables.
-
Rate Limiting: Implement rate limiting when exposing the agent in a web API.
-
Caching: Cache generation results to avoid redundant API calls.
-
Validation: Always validate generated metadata before using in production.
-
Error Recovery: Implement retry logic with exponential backoff for API failures.
-
Type Safety: Use TypeScript for type safety with the agent API.
-
Testing: Test generated applications thoroughly before deployment.
Next Steps
- See CLI Usage for command-line tools
- Read Generating Apps for prompting best practices
- Check Building Apps for using ObjectQL in AI applications