This guide explains how to securely manage API keys and credentials for external services.
Overview
DanteLabs Agentic School plugins integrate with various external services. This skill provides a way to manage API keys and credentials securely and consistently.
Supported Services
| Service | Purpose | Environment Variable | Issuance URL |
|---|---|---|---|
| Kie.ai | Image/Video Generation | KIEAI_API_KEY, KIE_AI_API_KEY |
https://kie.ai |
| OpenRouter | LLM API Routing | OPENROUTER_API_KEY |
https://openrouter.ai |
| OpenAI | GPT API | OPENAI_API_KEY |
https://platform.openai.com |
| Anthropic | Claude API | ANTHROPIC_API_KEY |
https://console.anthropic.com |
Credential Management Methods
Method 1: Centralized Credentials (Recommended)
~/.claude/auth/ Create a per-service environment file in the directory.
~/.claude/auth/
├── kie-ai.env # Kie.ai API 키
├── openrouter.env # OpenRouter API 키
├── openai.env # OpenAI API 키
└── anthropic.env # Anthropic API 키
Kie.ai Configuration
# ~/.claude/auth/kie-ai.env
KIEAI_API_KEY=your_api_key_here
KIE_AI_API_KEY=your_api_key_here
OpenRouter Configuration
# ~/.claude/auth/openrouter.env
OPENROUTER_API_KEY=your_api_key_here
Method 2: Per-Skill Directory .env
Create an individual .env file in each skill directory.
# ~/.claude/skills/kie-image-generator/.env
KIEAI_API_KEY=your_api_key_here
# ~/.claude/skills/kie-video-generator/.env
KIE_AI_API_KEY=your_api_key_here
Method 3: System Environment Variables
Set them directly in your shell profile.
# ~/.zshrc 또는 ~/.bashrc
export KIEAI_API_KEY=your_api_key_here
export KIE_AI_API_KEY=your_api_key_here
export OPENROUTER_API_KEY=your_api_key_here
Loading Environment Files
Loading in Scripts
from dotenv import load_dotenv
import os
# 중앙화된 인증 파일 로드
load_dotenv(os.path.expanduser("~/.claude/auth/kie-ai.env"))
# 또는 스킬 디렉토리의 .env 로드
load_dotenv()
api_key = os.getenv("KIEAI_API_KEY")
Loading in Shell
# 단일 서비스
source ~/.claude/auth/kie-ai.env
# 모든 인증 파일 로드
for f in ~/.claude/auth/*.env; do source "$f"; done
Security Guidelines
Recommendations
-
Git Exclusion:
.envAdd the.gitignorefile to# .gitignore .env *.env -
File Permissions: Set credential files so that only you can read them
chmod 600 ~/.claude/auth/*.env -
Backup: Back up credential files in a safe place
cp -r ~/.claude/auth ~/.claude/auth.backup
Prohibited Actions
- Do not hardcode API keys in code
- Do not commit API keys to Git
- Do not share API keys on public channels
- Be careful not to expose API keys in screenshots
Checking Credits/Usage
Check Kie.ai Credits
# 이미지 생성 크레딧
python ~/.claude/skills/kie-image-generator/scripts/generate_image.py --credits
# 비디오 생성 크레딧
python ~/.claude/skills/kie-video-generator/scripts/generate_video.py --credits
Usage Monitoring
# 생성 후 출력 예시
💰 Credits used: 45.0 ($0.23)
Remaining: 837.5 credits ($4.19)
Troubleshooting
API Key Errors
| Error Code | Cause | Solution |
|---|---|---|
| 401 | Invalid API key | Recheck the API key |
| 402 | Insufficient credits | Top up credits |
| 403 | No permission | Check API key permissions |
Checking Environment Variable Loading
# 환경변수 설정 확인
echo $KIEAI_API_KEY
# .env 파일 내용 확인 (주의: 터미널 기록에 남음)
cat ~/.claude/auth/kie-ai.env
auth-loader Skill Integration
auth-loader If the skill is installed, you can manage credentials interactively.
# 서비스 목록 확인
/auth-loader list
# 새 서비스 추가
/auth-loader add kie-ai
# 인증 정보 검증
/auth-loader validate kie-ai
Project Directory Structure
All agents and skills save their outputs in the standard directory structure below.
{project}/
├── assets/ # 이미지, 비디오 등 정적 에셋
│ ├── images/ # AI 생성 이미지
│ └── videos/ # AI 생성 비디오
├── reports/ # 마케팅 문서 및 분석 리포트
│ ├── brand/ # 브랜드 분석 문서
│ ├── persona/ # 페르소나 카드
│ ├── strategy/ # 전략 문서
│ └── content/ # 카피, 스크립트
├── scripts/ # 실행 스크립트
│ └── automation/ # 자동화 스크립트
└── tmp/ # 임시 파일 (작업 완료 후 삭제 가능)
Directory Description
| Directory | Purpose | Example |
|---|---|---|
assets/ |
Static assets such as images and videos | product-hero.png, brand-video.mp4 |
reports/ |
Marketing documents and analysis results | brand-strategy-brief.md, persona-card.md |
scripts/ |
Automation and utility scripts | generate_thumbnails.py |
tmp/ |
Temporary files (intermediate outputs) | draft-v1.md, temp-image.png |
Automatic Directory Creation
When an agent creates a file, it automatically creates the directory if it does not exist.
# 필요 시 디렉토리 생성
mkdir -p assets/images assets/videos
mkdir -p reports/brand reports/persona reports/strategy reports/content
mkdir -p scripts/automation
mkdir -p tmp
Related Skills
kie-image-generator: AI image generation (uses Kie.ai API)kie-video-generator: AI video generation (using Kie.ai API)auth-loader: Interactive authentication management tool