Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Openai Api Pro

ASecurity

OpenAI API guidance — chat/completions, function calling, structured outputs, embeddings, assistants, and cost control.

2 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentspythongoapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add aicodedecode/awesome-muse-skills --skill openai-api-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Openai Api Pro?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Openai Api Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aicodedecode-openai-api-pro/badge)](https://www.skillsdirectory.com/skills/aicodedecode-openai-api-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: openai-api-pro
description: OpenAI API guidance — chat/completions, function calling, structured outputs, embeddings, assistants, and cost control.
category: development
---

## Overview

The OpenAI API is the reference LLM API: chat completions, structured outputs, function calling, embeddings, image/audio models, and batch processing. The patterns here — message roles, JSON mode, tool definitions, streaming — transfer to most other providers, so fluency with this API pays beyond OpenAI itself.

This skill covers using the API well: message construction, structured outputs, function calling, embeddings, the right model for the job, and the cost/latency controls that keep bills sane.

## When to use

- Calling the OpenAI API (chat, structured outputs, tools).
- Designing function-calling / tool-use integrations.
- Getting reliable JSON from the model.
- Choosing models (flagship vs mini vs reasoning).
- Controlling cost and latency.
- Using embeddings for search/RAG.
- Migrating between OpenAI and compatible APIs.

## Core concepts

- **Messages API.** `system` / `user` / `assistant` (+ `tool`) roles; conversation as a message list. System prompts set behavior; keep them focused — one job per system prompt beats a constitution.
- **Model selection.** Flagship (hardest reasoning), mini (cheap/fast for simple tasks), reasoning models (o-series — for math/code/logic with visible effort). Right-size per task: classify with mini, reason with flagship. The cost spread is 10-100x.
- **Structured outputs.** `response_format` with JSON schema (strict mode) — guaranteed schema-conforming JSON. For anything downstream parses, structured outputs beat "please return JSON" prompting.
- **Function calling / tools.** `tools` array with JSON-schema parameters; the model returns `tool_calls`, you execute and return results. Tools are how LLMs act — design them like APIs: clear names, descriptions, narrow scope.
- **Streaming.** `stream: true` — tokens as they're generated; essential UX for chat (perceived latency), plus early cancellation. Handle tool-call streaming's chunked-argument assembly.
- **Embeddings.** `text-embedding-3-*` — `large` for quality, `small` for cost; `dimensions` parameter for truncated vectors (Matryoshka — shorter vectors, minimal quality loss). Normalize for cosine similarity; batch inputs.
- **Temperature/top_p.** Temperature 0 for deterministic tasks (classification, extraction); higher for creative. `top_p` as the alternative sampler — tune one, not both.
- **Reasoning effort.** For o-series: `reasoning_effort` (low/medium/high) trades tokens for thought — low for quick checks, high for hard problems. Don't pay for deep reasoning on shallow tasks.
- **Batch API.** 50% discount for non-urgent workloads (24h turnaround) — embeddings backfills, evaluations, bulk classification. The easiest cost win for offline work.
- **Caching.** Prompt caching (automatic on long prefixes) — repeated system prompts + context cost a fraction after the first call. Structure prompts with stable prefixes to maximize cache hits.
- **Rate limits and retries.** Tiered RPM/TPM; exponential backoff with jitter on 429s; request timeouts. The API is a shared resource — design clients that degrade gracefully.
- **Safety.** Moderation endpoint for user content, instruction hierarchy (system > developer > user), no secrets in prompts, PII awareness. Validate tool outputs before acting on them.
- **Assistants API (awareness).** The stateful assistants abstraction exists but the ecosystem has moved toward self-managed threads + tools — know it exists, prefer explicit control for new builds.
- **Evals.** Model-graded and deterministic evals on golden sets — run before every prompt/model change. The API makes it easy to call models; evals make it safe to change them.
- **Multimodal endpoints.** Image generation/editing, Whisper transcription, TTS speech, image inputs for vision — beyond text; audio models power voice interfaces.
- **Fine-tuning.** Supervised fine-tuning for consistent style/format on narrow tasks — when prompting plateaus; needs evals, and doesn't reliably inject new knowledge.

## Practical workflow

1. **Start with the right model.** Prototype on flagship, then distill: can mini handle it with a better prompt? Measure quality, not vibes.
2. **Structure the messages.** Focused system prompt, clear user message, examples where format matters:
   ```python
   response = client.chat.completions.create(
       model="gpt-4.1-mini",
       messages=[
           {"role": "system", "content": "Extract invoice fields. Return JSON only."},
           {"role": "user", "content": invoice_text},
       ],
       response_format={"type": "json_schema",
                        "json_schema": {"name": "invoice", "strict": True,
                                        "schema": Invoice.model_json_schema()}},
       temperature=0,
   )
   ```
3. **Use structured outputs.** JSON schema strict mode for all machine-consumed output; Pydantic models as the schema source; validate anyway.
4. **Design tools carefully.** Narrow functions, precise descriptions, typed parameters; execute server-side; return concise results (token-efficient tool outputs).
5. **Stream to users.** `stream=True` for interactive paths; assemble tool-call arguments from chunks correctly.
6. **Batch the offline work.** Batch API for evaluations, backfills, bulk jobs — half price for patience.
7. **Control costs.** Token logging per request, budgets and alerts, prompt caching via stable prefixes, right-sized models, max_tokens limits.
8. **Evaluate changes.** Golden dataset + model-graded evals in CI; every prompt or model change runs the suite before shipping.

## Common pitfalls

- **Flagship for everything** — 50x cost for tasks mini handles; right-size per task.
- **Unstructured JSON prompting** — "return JSON" without schema; strict structured outputs.
- **Temperature > 0 for extraction** — nondeterministic structured tasks; temperature 0.
- **No retries/backoff** — 429s crashing clients; exponential backoff with jitter.
- **Ignoring prompt caching** — unstable prompt prefixes; stable long prefixes for cache hits.
- **Batch API unused** — paying full price for offline work; 50% off for 24h turnaround.
- **Tool sprawl** — dozens of vague tools; narrow, well-described, few.
- **No evals** — prompt changes by feel; golden sets + graded evals.
- **Secrets in prompts** — API keys in context sent to third parties; scrub and scope.
- **Streaming mishandled** — broken tool-call assembly; handle chunked arguments.
- **No token logging** — surprise bills; log and budget per request/feature.
- **Reasoning overkill** — high effort on trivial tasks; match effort to difficulty.
- **Embedding without normalization** — cosine on unnormalized vectors; normalize (or use dot-product-aware stores).

Attribution

aicodedecodeaicodedecode
View sourceSee grades on GitHubMore from aicodedecode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →