1.0.4 • Published 6 months ago
@bluefly/api-client v1.0.4
Bluefly API Client Library
TypeScript client library for the Bluefly AI Platform API.
Current Status
Status: Core functionality working, recently cleaned up
Focus: API client generation and management for Drupal modules
What Works
- Basic TypeScript client framework
- OpenAPI 3.1.0 specification support
- Type definitions for API responses
- Basic authentication (API Key, Bearer Token)
- Error handling for common HTTP status codes
- Rate limiting implementation
What's In Development
- Advanced retry mechanisms
- Circuit breaker pattern
- Comprehensive caching
- OAuth2 flow implementation
- Advanced validation
Installation
npm install @bluefly/api-clientBasic Usage
import { Configuration, AgentApi } from '@bluefly/api-client';
// Configure the client
const config = new Configuration({
basePath: 'https://api.bluefly.ai',
apiKey: 'your-api-key',
});
// Create an API instance
const agentApi = new AgentApi(config);
// Use the API
async function createAgent() {
try {
const agent = await agentApi.createAgent({
agent: {
name: 'My Agent',
description: 'A test agent',
model: 'gpt-4',
parameters: {
temperature: 0.7,
max_tokens: 1000,
},
},
});
console.log('Created agent:', agent);
} catch (error) {
console.error('Error creating agent:', error);
}
}Development
Prerequisites
- Node.js 20+
- npm 9+
Setup
- Clone the repository
- Install dependencies:
npm install
Building
npm run buildTesting
# Run all tests
npm run test:all
# Run unit tests
npm run test:unit
# Run integration tests
npm run test:integrationGenerating Client
The client is generated from the OpenAPI specification:
npm run generate:clientValidation
Validate the OpenAPI specification:
npm run validate:specAuthentication
Currently supports:
- API Keys
- Bearer tokens (JWT)
const config = new Configuration({
// API Key
apiKey: 'your-api-key',
// JWT Bearer token
bearerToken: 'your-jwt-token',
});Error Handling
Basic error handling is implemented:
try {
await agentApi.runAgent({
/* ... */
});
} catch (error) {
if (error.status === 429) {
console.log('Rate limit exceeded');
} else if (error.status === 401) {
console.log('Authentication required');
} else {
console.log('Unexpected error:', error.message);
}
}Project Structure
bfapiclient/
├── src/
│ ├── core/ # Core client functionality
│ ├── models/ # TypeScript type definitions
│ ├── services/ # API service classes
│ └── utils/ # Utility functions
├── openapi/ # OpenAPI specifications
├── __tests__/ # Test files
└── docs/ # DocumentationContributing
- Follow TypeScript best practices
- Write tests for new features
- Update OpenAPI specifications
- Use conventional commit messages
- Ensure all tests pass before pushing
Known Limitations
- OAuth2 flow not fully implemented
- Advanced caching not yet available
- Circuit breaker pattern in development
- Some edge cases in error handling need refinement
Troubleshooting
Common Issues
- Build errors: Clear node_modules and reinstall
- Type errors: Regenerate client from OpenAPI spec
- Authentication fails: Check token format and permissions
Debug Mode
Run with debug output:
DEBUG=bfapiclient:* npm run testLicense
MIT
Last Updated: June 2025
📚 Platform Documentation
- Complete Platform Overview: Bluefly AI Platform Documentation
- Technical Architecture: System Architecture & Data Flow
- Implementation Guides: Central Guides
- Module Documentation: All Modules
- Package Documentation: All Packages
This project is part of the Bluefly AI Platform - Private LLM enterprise solution with complete data sovereignty.
Last Updated: June 09, 2025