使用 OATDA 统一 LLM API 生成文本;在用户希望使用特定 LLM 提供商(如 OpenAI、Anthrop...)生成、撰写或补全文本时触发。
Generate text from 10+ LLM providers through OATDA's unified API.
All commands need the OATDA API key. Resolve it inline for each exec call:
bash
export OATDA_API_KEY="${OATDA_API_KEY:-$(cat ~/.oatda/credentials.json 2>/dev/null | jq -r '.profiles[.defaultProfile].apiKey' 2>/dev/null)}"
If the key is empty or null, tell the user to get one at https://oatda.com and configure it.
Security: Never print the full API key. Only verify existence or show first 8 chars.
User saysProviderModelgpt-4oopenaigpt-4ogpt-4o-miniopenaigpt-4o-minio1openaio1claude, sonnetanthropicclaude-3-5-sonnethaikuanthropicclaude-3-5-haikuopusanthropicclaude-3-opusgeminigooglegemini-2.0-flashgemini-1.5googlegemini-1.5-prodeepseekdeepseekdeepseek-chatmistralmistralmistral-largegrokxaigrok-2qwenalibabaqwen-max
Default: openai / gpt-4o if no model specified. If user provides provider/model format, split on /.
⚠️ Models update frequently. If a model ID fails, query
oatda-list-modelsfor the latest available models.
bash
export OATDA_API_KEY="${OATDA_API_KEY:-$(cat ~/.oatda/credentials.json 2>/dev/null | jq -r '.profiles[.defaultProfile].apiKey' 2>/dev/null)}" && \
curl -s -X POST "https://oatda.com/api/v1/llm" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OATDA_API_KEY" \
-d '{
"provider": "<PROVIDER>",
"model": "<MODEL>",
"prompt": "<USER_PROMPT>",
"temperature": 0.7,
"maxTokens": 4096
}'
temperature: 0 (deterministic) to 2 (creative). Default: 0.7maxTokens: Max tokens to generate. Default: 4096 (max 128000 for some models)stream: Set to true for streaming (not recommended via curl)json
{
"success": true,
"provider": "openai",
"model": "gpt-4o",
"response": "The generated text content...",
"tokenUsage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175,
"cost": 0.001375
}
}
Present the response field to the user. Optionally mention token usage and cost.
HTTP StatusMeaningAction401Invalid API keyTell user to check key at https://oatda.com/dashboard/api-keys402Insufficient creditsTell user to check balance at https://oatda.com/dashboard/usage429Rate limitedWait 5 seconds and retry once400Bad request / model not foundCheck model format, suggest oatda-list-models
User: "Write a haiku about code using claude"
bash
export OATDA_API_KEY="${OATDA_API_KEY:-$(cat ~/.oatda/credentials.json 2>/dev/null | jq -r '.profiles[.defaultProfile].apiKey' 2>/dev/null)}" && \
curl -s -X POST "https://oatda.com/api/v1/llm" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OATDA_API_KEY" \
-d '{
"provider": "anthropic",
"model": "claude-3-5-sonnet",
"prompt": "Write a haiku about code",
"temperature": 0.7,
"maxTokens": 256
}'
prompt as a plain string, NOT a messages arrayprovider/model into separate JSON fieldsmaxTokensoatda-list-models to see all available modelsoatda-vision-analysis for image analysis tasks