What is an API Key?
An API Key is a digital password for accessing external services. In CodeFreeAI, you need an API Key to use AI models or external platforms.
π Concept of API Key
Simple Analogy
An API Key is like a Hotel Key Card:
- π¨ Hotel = External Service (ChatGPT, Slack, etc.)
- π Key Card = API Key
- π€ You = CodeFreeAI Workflow
Just as you need a key card to enter a room (service), You need an API Key to use an external service.
Technical Definition
An API Key is a token for Authentication and Authorization:
- Authentication: Verifies "Who you are"
- Authorization: Determines "What you can do"
- Billing: Tracks usage and charges fees
π Types of API Keys
Common Formats
Each service has a different API Key format:
ChatGPT (OpenAI)
sk-proj-1234567890abcdefghijklmnopqrstuvwxyz
Claude (Anthropic)
sk-ant-api03-1234567890abcdefghijklmnopqrstuvwxyz
Gemini (Google)
AIzaSyD1234567890abcdefghijklmnopqrstuvw
Slack Bot Token
xoxb-1234567890-1234567890-abcdefghijklmnopqrstuvwxyz
Telegram Bot Token
123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567890
π What does an API Key do?
1. Identity Verification
[Workflow] ---> "I am sk-proj-123..."
|
v
[OpenAI Server]
|
v
"Verified. Access Granted"
2. Usage Tracking
Through the API Key, service providers:
- β Track how much you used
- β Charge based on usage
- β Manage usage limits
- β Provide statistics
3. Permission Control
Different permissions are granted for each API Key:
- Read Only
- Write Access
- Admin Privileges
- Restricted Features
π° API Keys and Costs
Free vs Paid
| Type | Description | Example |
|---|---|---|
| Free Service | API Key needed but no cost | Telegram, Slack, Discord |
| Free Quota | Free up to a certain amount | Gemini (60/min) |
| Pay-as-you-go | Charged by usage | ChatGPT, Claude, Grok |
Billing Methods
Token-based (AI Services)
Input Tokens + Output Tokens = Total Tokens
Total Tokens Γ Unit Price = Cost
Example: ChatGPT GPT-4o
- Input: $0.15 / 1M Tokens
- Output: $0.60 / 1M Tokens
Request-based (Some Services)
API Call Count Γ Unit Price = Cost
π‘οΈ API Key Security
Why is API Key important?
If an API Key is exposed:
- β Others can use the service with your key
- β Fees charged for unused usage
- β Usage limit exceeded
- β Risk of account suspension
Real Case
Uploaded API Key to GitHub
β
Bot automatically collects key
β
Abused for crypto mining etc.
β
Millions charged πΈ
This actually happens!
How to Manage Safely
β Do's
- Save as Environment Variable
- Regenerate key periodically
- Set usage alerts
- Use private repositories
β Don'ts
- Upload to public GitHub
- Share screenshots
- Print to logs
- Share with multiple people
π API Key Lifecycle
1. Issuance
Sign up β Verify Account β Generate API Key
2. Usage
Input to Workflow β Call Service β Return Result
3. Management
Monitor Usage β Adjust Limits β Check Stats
4. Regeneration
Regenerate key when:
- π Key is exposed
- π Regular security maintenance
- β Suspicious usage pattern detected
- π« App no longer in use
π― Usage in CodeFreeAI
How to Input API Key
- Edit Workflow
- Click Node
- Enter in API Key Field
- Save
Security Processing
CodeFreeAI handles API Keys by:
- π Storing encrypted
- π« Not leaving in logs
- ποΈ Masking (*...)
- π Sending securely
Using in Multiple Workflows
Same API Key can be reused in multiple workflows:
Workflow A \
Workflow B ---> [Same API Key]
Workflow C /
Note: Usage is aggregated!
π‘ API Key vs Other Auth Methods
| Method | Description | Pros | Cons |
|---|---|---|---|
| API Key | Fixed string | Simple | Exposure risk |
| OAuth | Token-based | Secure | Complex |
| JWT | Encrypted token | High security | Hard to implement |
CodeFreeAI uses API Key method for simplicity.
π Further Learning
Want to know more about API?
CodeFreeAI Related Guides
β FAQ
Q: Can I use it without an API Key? A: AI services require it, but some nodes like Trigger or Http Response do not.
Q: Can multiple people share an API Key? A: Technically yes, but not recommended for security. Issue individually.
Q: What if my API Key is exposed? A: Immediately delete/regenerate the key on the service and check usage.
Q: Who pays for the API Key cost? A: The person who issued the key (Service account owner) pays.
Q: Is there a test API Key? A: Some services (like Gemini) provide free tiers that can be used for testing.