AI API Keys
The AI API Keys endpoints allow you to create and manage repository-specific API keys for AI-powered features. These keys provide secure, scoped authentication for AI operations within individual repositories.
Overview
AI API Keys are specialized authentication credentials that enable AI-powered features and services for specific repositories. Unlike workspace-level AI LLM configurations, these keys are repository-scoped and designed for service-to-service authentication.
Key Characteristics
Repository-Scoped: Each API key is tied to a single repository
AI Provider Specific: Keys are associated with specific AI providers (OpenAI, Google, Anthropic, etc.)
Secure Generation: Keys and secrets are cryptographically generated
One-Time Secret Display: Secrets are only shown during creation
Soft Delete: Deleted keys maintain audit history
Access Controlled: Respects repository-level permissions
Supported AI Providers
OPENAI - OpenAI (GPT-5, GPT-4, GPT-3.5, etc.)
GOOGLE - Google AI (Gemini, PaLM, etc.)
ANTHROPIC - Anthropic (Claude models)
AWS - Amazon Bedrock and AWS AI services
OTHER - Custom or additional AI provider endpoints
Available Endpoints
Key Management
PUT/repo/{policyId}/ai/apikey
Update an AI API key's properties.
DELETE /repo/{repoId}/ai/apikey/{apikeyId}
Delete an AI API key.
Common Use Cases
1. Creating an AI API Key for a Repository
2. Listing Repository API Keys
3. Updating an API Key
4. Rotating API Keys
Security Best Practices
1. Secret Management
Critical: The API secret is only returned once during creation. Store it securely immediately.
2. Key Rotation
Regularly rotate API keys to maintain security:
Create a new API key
Update services to use the new key
Verify the new key works correctly
Delete the old key
Update documentation with the new key ID
3. Access Control
Only grant repository access to users who need it
Use descriptive names to track key usage
Monitor key usage through audit logs
Delete unused keys promptly
4. Separation of Environments
Create separate keys for different environments:
API Key vs AI LLM Configuration
Understanding the difference between these two concepts:
AI LLM Configuration (Workspace-Level)
Configured at the workspace level
Contains AI provider endpoints and credentials
Used to establish connection to AI services
Managed through AI LLM Management APIs
AI API Keys (Repository-Level)
Created at the repository level
Provides authentication for repository-specific AI operations
Scoped to individual repositories
Managed through these AI API Key endpoints
Relationship: AI API Keys enable AI features within a repository, which may utilize AI LLM Configurations for actual AI provider communication.
Response Data
Key Creation Response
When you create an API key, you receive:
Key List Response
When listing keys, you receive:
Note: The secret is never returned in list operations or subsequent requests.
Error Handling
Common error scenarios and how to handle them:
403 Forbidden
Cause: User doesn't have access to the repository
404 Not Found
Cause: API key or repository doesn't exist
500 Internal Server Error
Cause: Server-side error during operation
Audit and Compliance
All API key operations trigger system events for audit purposes:
Created: When a new API key is generated
Updated: When key properties are modified
Deleted: When a key is soft-deleted
These events include:
Timestamp of the operation
User who performed the action
Organization and workspace context
Key metadata (without exposing secrets)
Permissions
All AI API Key endpoints require authentication via BearerAuth. The following access rules apply:
Users must have access to the repository to manage its API keys
Only active (non-deleted) keys can be updated
Deleted keys are filtered from list operations
Repository administrators have full access to manage keys
TypeScript Client Library
The Flashback TypeScript client provides convenient methods for all AI API Key operations:
Best Practices Summary
Store Secrets Securely: Never log or expose API secrets
Rotate Regularly: Implement a key rotation schedule
Use Descriptive Names: Make keys easy to identify and manage
Monitor Usage: Track key usage through audit logs
Separate Environments: Use different keys for prod/dev/test
Delete Unused Keys: Remove keys that are no longer needed
Verify Before Deleting: Test new keys before removing old ones
Document Keys: Maintain internal documentation of key purposes
Related Documentation
AI LLM Management APIs - Configure AI provider connections at workspace level
Repository APIs - Manage repositories and their configurations
Policy APIs - Set up AI usage policies and governance
Next Steps
Create your first AI API key for a repository
Securely store the secret in your secrets management system
Configure your AI services to use the key for authentication
Monitor usage through audit logs
Set up a key rotation schedule
Last updated
Was this helpful?