openai-api
OpenAI API for GPT completions, function calling, assistants, embeddings, and more
What this skill does
# openai-api
## Purpose
This skill provides direct access to the OpenAI API for tasks like generating text completions, handling function calls, managing assistants, and creating embeddings. It's designed for AI agents to integrate OpenAI's capabilities into workflows.
## When to Use
Use this skill when you need dynamic text generation (e.g., for chatbots), embeddings for semantic search, or function calling for tool integration. Apply it in scenarios requiring real-time AI responses, such as code generation, content summarization, or data analysis. Avoid it for simple tasks; reserve for complex AI-driven operations where OpenAI's models outperform local alternatives.
## Key Capabilities
- Text completions: Use the /completions endpoint for basic prompt-based generation with models like text-davinci-003.
- Chat completions: Leverage /chat/completions for conversational AI, supporting role-based messages and tools.
- Function calling: Enable tools via /chat/completions by defining functions in the request body for dynamic API interactions.
- Assistants: Manage custom assistants through /assistants endpoints for persistent AI agents with tools and files.
- Embeddings: Generate vector representations via /embeddings for applications like similarity search.
- Fine-tuning: Access /fine-tunes for customizing models, though this requires specific input formats like JSONL files.
## Usage Patterns
Always set the API key via environment variable: export OPENAI_API_KEY=your_api_key. Make requests to the base URL https://api.openai.com/v1/. For CLI or script usage, use tools like curl or OpenAI's SDK. Structure requests with JSON payloads, including parameters like model (e.g., gpt-3.5-turbo) and max_tokens (e.g., 150). Handle rate limits by implementing retry logic with exponential backoff. To use function calling, include a "tools" array in your request and check the response for "tool_calls".
## Common Commands/API
Interact via HTTP requests or the OpenAI SDK. For authentication, include the header: Authorization: Bearer $OPENAI_API_KEY. Key endpoints:
- For text completion: POST to /completions with body {"model": "text-davinci-003", "prompt": "Hello world", "max_tokens": 50}.
Example snippet:
```
curl https://api.openai.com/v1/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-davinci-003", "prompt": "Explain AI"}'
```
- For chat completion: POST to /chat/completions with body {"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello"}], "tools": [...]}.
Example snippet:
```
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Summarize this: AI is changing the world"}]}'
```
- For embeddings: POST to /embeddings with body {"model": "text-embedding-ada-002", "input": "Your text here"}.
Example: Use in code as: response = openai.Embedding.create(model="text-embedding-ada-002", input="Hello")
- Config format: Requests often use JSON like {"temperature": 0.7, "top_p": 1} for controlling output randomness.
## Integration Notes
Integrate by importing the OpenAI SDK in your language (e.g., pip install openai for Python). Set up event-driven patterns, like triggering completions on user input. For function calling, define tools as a list of dictionaries (e.g., {"type": "function", "function": {"name": "get_weather", "parameters": {"location": "string"}}}). Ensure compatibility with other AI APIs by standardizing response formats. Use webhooks for assistants to handle asynchronous events. Test integrations with mock servers to avoid real API costs.
## Error Handling
Common errors include 429 (rate limit exceeded), 401 (unauthorized), and 400 (bad request). Check response status codes and parse error messages from the JSON body (e.g., {"error": {"message": "Invalid model", "type": "invalid_request_error"}}). Implement retry logic for transient errors: use a loop with time.sleep() for delays. For authentication failures, verify $OPENAI_API_KEY is set and not expired. Log errors with details like error code and message, then fallback to default responses or alternative skills.
## Graph Relationships
- Connected to cluster: ai-apis
- Related tags: ai-apis, api
- Potential links: Integrates with skills in the same cluster, such as other AI APIs for combined workflows; depends on authentication services for key management.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.