-
Notifications
You must be signed in to change notification settings - Fork 0
Guide API Keys
GitHub Actions edited this page Jan 25, 2026
·
2 revisions
Diese Anleitung zeigt dir, wie du API-Keys für LLM-Features und andere externe Services konfigurierst.
Windows (PowerShell):
$env:OPENAI_API_KEY = "sk-..."
$env:ANTHROPIC_API_KEY = "sk-ant-..."
$env:GOOGLE_GEMINI_API_KEY = "AIza..."Windows (CMD):
set OPENAI_API_KEY=sk-...
set ANTHROPIC_API_KEY=sk-ant-...
set GOOGLE_GEMINI_API_KEY=AIza...Linux/Mac:
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_GEMINI_API_KEY="AIza..."fn getApiKey(): string {
// Nutze config.get_env() für Umgebungsvariablen
return config.get_env("OPENAI_API_KEY", "");
}
@POST("/api/chat")
fn chat(message: string): string {
let llm = LLMClient.new("openai", getApiKey());
let result = await llm.generate(message);
return result;
}
-
Umgebungsvariable:
OPENAI_API_KEY -
Format:
sk-... - Erstellen: platform.openai.com/api-keys
-
Umgebungsvariable:
ANTHROPIC_API_KEY -
Format:
sk-ant-... - Erstellen: console.anthropic.com
-
Umgebungsvariable:
GOOGLE_GEMINI_API_KEY -
Format:
AIza... - Erstellen: makersuite.google.com/app/apikey
-
Umgebungsvariable:
PINECONE_API_KEY - Erstellen: app.pinecone.io
-
Umgebungsvariable:
WEAVIATE_API_KEY - Erstellen: cloud.weaviate.io
-
Umgebungsvariable:
QDRANT_API_KEY - Erstellen: cloud.qdrant.io
velin config init{
"ml": {
"llm": {
"provider": "openai",
"apiKey": "${OPENAI_API_KEY}",
"anthropicApiKey": "${ANTHROPIC_API_KEY}",
"geminiApiKey": "${GOOGLE_GEMINI_API_KEY}",
"model": "gpt-4"
}
}
}Wichtig: Nutze ${VARIABLE_NAME} für Umgebungsvariablen, nicht die Keys direkt!
use config;
fn getConfig(): AppConfig {
return config.loadConfig("velin.config.json");
}
@POST("/api/chat")
fn chat(message: string): string {
let cfg = getConfig();
let llm = LLMClient.new(cfg.ml.llm.provider, cfg.ml.llm.apiKey);
return await llm.generate(message);
}
-
Nie API-Keys im Code hardcoden
// ❌ SCHLECHT let apiKey = "sk-1234567890abcdef"; // ✅ GUT let apiKey = config.get_env("OPENAI_API_KEY", ""); -
Nutze Umgebungsvariablen
- Lokal:
.envDatei (nicht committen!) - Production: Environment Variables im Deployment
- Lokal:
-
Nutze velin.config.json mit Variablen
{ "ml": { "llm": { "apiKey": "${OPENAI_API_KEY}" } } } -
Gitignore beachten
.env velin.config.json *.key
- ❌ API-Keys in Git committen
- ❌ API-Keys in Code hardcoden
- ❌ API-Keys in Logs ausgeben
- ❌ API-Keys in öffentlichen Repositories teilen
Für Tests kannst du den "local" Provider verwenden:
@POST("/api/chat")
fn chat(message: string): string {
// "local" simuliert Antworten ohne API-Kosten
let llm = LLMClient.new("local", "");
return await llm.generate(message);
}
- Tutorial 7: ML/LLM - Vollständiges LLM-Tutorial
- Security Guide - Security-Best-Practices
- 02-llm-chat Beispiel - Praktisches Beispiel
-
Prüfe, ob die Umgebungsvariable gesetzt ist:
# Windows echo $env:OPENAI_API_KEY # Linux/Mac echo $OPENAI_API_KEY
-
Prüfe, ob die Variable im aktuellen Terminal verfügbar ist
-
Starte den Terminal neu, wenn nötig
- Prüfe, ob der Key korrekt kopiert wurde
- Prüfe, ob der Key noch gültig ist
- Erstelle einen neuen Key, falls nötig
Letzte Aktualisierung: 2026-01-30
Version: 3.1.0
- Compiler Architecture
- Pass-Verlauf
- Type Inference
- Code Ordering
- IR Representation
- Borrow Checker
- Code Generation
- Multi-Target Compilation
- Module Resolution
- Framework Integration
- Parallelization
- AI Compiler Passes
- Prompt Optimizer
- System Generation
- Basics
- APIs
- Security
- Database
- Validation
- Authentication
- ML/LLM
- Intelligence Features
- Type Inference
- ML Training
- Pattern Matching
- Closures
- Collections
- HTTP Client
- String Interpolation
- Debugger
- Vektor-Datenbanken
- CLI Reference
- API Keys Setup
- Advanced
- Backend
- Security Best Practices
- AI/ML
- Auto Imports
- Plugin Development