API Keys
API keys are secure credentials that allow you to authenticate and access Chroma Golem's AI services. They enable you to implement text and image generation into your games with just a few lines of code.
Contents
Overview
API keys are unique authentication credentials that give your games access to Chroma Golem's AI services. Each API key is associated with either your personal account or an organization you belong to.
Key Features
- Secure authentication for AI API access
- Default AI model preferences for consistent results
- Detailed usage analytics and monitoring
- Shareable between team members (organization keys)
- Support for both text and image generation
Types of API Keys
Personal API Keys
Tied to your individual account and credits. Best for solo developers or personal projects.
Organization API Keys
Shared among team members with centralized billing and usage tracking. Perfect for studios and teams.
Best Practice: Create separate API keys for different games or projects to better track and manage usage. This also limits exposure if a key needs to be revoked.
Creating API Keys
Creating Personal API Keys
Personal API keys use your individual account's credit balance and are perfect for solo developers or independent projects.
Create API Key
To create a personal API key:
- 1 Navigate to the API Dashboard in your account
- 2 Enter a descriptive name for your API key (e.g., your game name)
- 3 Click the Create button to generate your key
Important: Make sure you don't share your personal API keys with anyone else. Add your contributors as team members to your organization instead.
Creating Organization API Keys
Organization API keys use your organization's credit balance and can be accessed by team members with appropriate permissions.
Create Organization API Key
To create an organization API key:
- 1 Navigate to the API Dashboard in your account
- 2 Select the organization from the dropdown menu
- 3 Enter a descriptive name for your API key
- 4 Click the Create button to generate your key
Note: You must have the appropriate permissions (admin or owner) within the organization to create API keys.
Managing API Keys
After creating API keys, you'll need to manage them throughout their lifecycle. This includes viewing, updating preferences, and occasionally revoking keys when needed.
Your API keys are listed on the API Dashboard. You can see:
- Key name and a partial view of the actual key
- When the key was created
- When the key was last used
- Total tokens and cost accrued by the key
- Organization badge for organization API keys
To view a full API key:
- Click on the masked API key
- The full key will be displayed and copied to your clipboard
Name | Key |
---|---|
My Game | cg-71d8...d19e |
Test Project Studio Name | cg-3a9c...f27b |
If you have many API keys or belong to multiple organizations, you can filter the keys displayed:
Available Filters
- All Keys - Shows all API keys you have access to
- Personal - Shows only your personal API keys
- Organization Specific - Shows API keys for a specific organization
Click on an API key's name to access its detailed view where you can:
- View the complete API key
- Update model preferences
- View detailed usage analytics
- Export usage data
To change model preferences:
- Navigate to the API key's detail page
- Select your preferred model from the dropdown
- Save your changes
You may need to delete an API key if:
- The key has been compromised
- The project the key was used for is now complete
- You need to better organize your keys
To delete an API key:
- Navigate to the API key's detail page
- Scroll to the bottom to find the "Danger Zone"
- Click the "Permanently destroy this API key" button
- Confirm the deletion in the dialog box
This action cannot be undone. This will permanently delete this API key and break any applications using it.
Warning: Deleting an API key immediately invalidates it. Any applications or services using that key will stop working. Always update your applications with a new API key before deleting an old one.
Organization Association
API keys can be associated with either your personal account or an organization you belong to. Managing these associations allows you to control which credit pool the API key uses and who has access to manage it.
The organization an API key is associated with determines:
- Billing: Which credit pool is charged for usage
- Access: Who can view and manage the key
- Analytics: Where usage data appears
- Permissions: What actions are allowed with the key
Note: By default, new API keys are associated with your personal account unless you specifically select an organization during creation.
You can change which organization an API key is associated with:
- Navigate to the API key's details page
- Find the Organization Association section
- Click the Change Organization button
- Select the desired organization from the dropdown
- Click Save Changes
Permission Requirements:
- You must be an owner or admin of the target organization
- For personal keys, only you can change their association
- For organization keys, you need admin rights in both the current and target organization
Important: Changing an API key's organization will immediately affect billing. Any future usage will be charged to the new organization's credit pool.
Tips for Managing API Key Organizations
Project Segregation
Create separate organizations for different projects to keep billing and analytics clear and separated.
Team Structure
Align organization structure with your team structure for better access control and role management.
Environment Separation
Use personal keys for development and testing, organization keys for production environments.
Regular Audits
Periodically review organization associations to ensure keys are correctly assigned to the right entities.
Model Selection
Each API key can have preferred AI models for both text and image generation. Setting default models ensures consistent results across your game and simplifies your API calls.
Text Generation Models
Model | Cost (GP per 1K tokens) | Best For |
---|---|---|
o1 | 18 | High-quality reasoning, complex tasks |
gpt-4-turbo | 0.09 | Advanced game mechanics, complex NPCs |
gpt-4o | 0.09 | Advanced games requiring multimodal capabilities |
o1-mini | 0.04 | Balanced performance and cost |
o3-mini | 0.013 | Efficient text generation with good reasoning |
gpt-3.5-turbo | 0.003 | Basic dialogue, simple game content |
gpt-4o-mini | 0.0018 | Cost-effective multimodal capabilities |
Image Generation Models
Model | Cost (GP per image) | Best For |
---|---|---|
SD XL | 500 | High-quality game assets and illustrations |
Image Generation Styles
skill_icon
item_icon
character_portrait
Each API key can have default models configured for both text and image generation:
- Navigate to the API key's detail page
- Find the "Preferred Text Model" dropdown
- Select your preferred model from the list
- Do the same for the "Preferred Image Model" if needed
- Save your changes
When making API requests, the system will automatically use your preferred model unless you explicitly specify a different one in your request.
Current cost: 0.003 GP per 1K tokens
Current cost: 500 GP per image
Tip: Choose models based on your game's needs. For simple dialogue or item descriptions, gpt-3.5-turbo is often sufficient and cost-effective. For complex NPCs or advanced game mechanics, consider using gpt-4o or o1-mini.
Usage Analytics
Chroma Golem provides detailed analytics for each API key, allowing you to monitor usage patterns, track costs, and make informed decisions about your AI implementation.
Key Performance Metrics
Player Analytics
Track usage patterns for individual players by including the client_id
parameter in your API requests.
- player_12345 142 requests (368 GP)
- player_67890 97 requests (215 GP)
- player_24680 89 requests (187 GP)
Usage Over Time
To access detailed usage analytics for your API key:
- Navigate to the API Keys dashboard
- Click on the name of the API key you want to analyze
- Select the Usage tab to view detailed metrics
- Use the date range filters to narrow down the time period
- View player-specific data by clicking on individual player IDs
Pro Tip: Include a unique client_id
with each API request to track usage by player, level, or game feature.
Download your usage data for offline analysis or reporting
Usage Insight: Analytics can help identify patterns in player behavior and optimize your credit usage. Consider implementing usage caps for individual players or monitoring for unusual spikes that might indicate inefficient prompt designs.
Security Best Practices
API keys provide direct access to your Chroma Golem account and credits. Following these security best practices helps protect your account and ensures your keys aren't misused.
API Key Security Do's
-
Use environment variables
Store API keys in environment variables, not in your code
-
Create separate keys for different purposes
Use distinct keys for development, testing, and production
-
Implement monitoring
Regularly review usage analytics to detect unusual activity
-
Rotate keys periodically
Create new keys and retire old ones on a regular schedule
-
Use secure storage
Consider password managers or secure key vaults for storage
API Key Security Don'ts
-
Don't commit API keys to code repositories
Never include API keys in source code or configuration files
-
Don't share API keys via unencrypted channels
Avoid sharing keys via email, chat, or other unencrypted methods
-
Don't embed API keys in client-side code
Never include keys in JavaScript code that runs in the browser
-
Don't use production keys for testing
Keep development and production keys separate
-
Don't ignore unexpected usage spikes
Investigate unusual activity immediately
Server-side API Calls (Recommended)
// Server-side environment variable
// .env file (not committed to repository)
CHROMA_GOLEM_API_KEY=cg-71d8...d19e
// Server code
require('dotenv').config();
const apiKey = process.env.CHROMA_GOLEM_API_KEY;
// Make API request
const response = await fetch('https://api.chromagolem.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
api_key: apiKey,
messages: [{ role: 'user', content: 'Generate a sword description' }],
client_id: 'player123'
})
});
This approach keeps your API key secure on your server and never exposes it to the client.
Key Rotation Strategy
- Create a new API key with the same settings
- Update your environment variables or secure storage with the new key
- Deploy the changes to your servers
- Monitor to ensure the new key works correctly
- Delete the old API key after confirming the new one is functioning
Recommended Rotation Schedule: Rotate keys at least quarterly or immediately after team member departures or suspected security incidents.
If You Suspect a Compromised Key
- Immediately delete the compromised API key
- Create a new API key with appropriate settings
- Update all applications to use the new key
- Review usage logs to assess potential damage
- Contact support if unusual activity is detected