Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/chandrudp29/skillhub/openai-patternsnpx skills add chandrudp29/skillhub --skill openai-patternsgit clone --depth 1 https://github.com/chandrudp29/skillhubWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/chandrudp29/skillhub/openai-patterns)<a href="https://agentmods.dev/skills/chandrudp29/skillhub/openai-patterns"><img src="https://agentmods.dev/badge/skills/chandrudp29/skillhub/openai-patterns.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00031 | $0.01251 |
| Opus 5 | $0.00015 | $0.00626 |
| Sonnet 5 | $0.00006 | $0.00250 |
| Haiku 4.5 | $0.00003 | $0.00125 |
Grade A, and why
openai-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.
When to Use
Apply when building or reviewing code that calls the OpenAI API. Covers GPT-4, GPT-4o, o1, and Responses API.
Core Rules
- Always handle rate limits with exponential backoff — they happen in production
- Set
max_tokenson every call — unbounded completions cause cost surprises - Log token usage per call — you need this for cost attribution and anomaly detection
- Use structured outputs (
response_format) when you need parseable data — regex on free text is fragile - Never hardcode API keys — use env vars, rotate quarterly
Model Selection
| Model | Best for | Approx cost |
|---|---|---|
gpt-4o-mini |
Classification, extraction, simple Q&A | ~$0.15/1M input |
gpt-4o |
Complex reasoning, code generation, long context | ~$2.50/1M input |
o1-mini |
Math, coding problems requiring multi-step reasoning | ~$1.10/1M input |
o1 |
Hardest reasoning tasks, research-grade | ~$15/1M input |
Rule: start with gpt-4o-mini and only upgrade if quality is insufficient. The gap is smaller than you think.
Basic Call Pattern
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain transformer attention in one paragraph."},
],
max_tokens=500,
temperature=0.7,
)
text = response.choices[0].message.content
usage = response.usage # prompt_tokens, completion_tokens, total_tokens
Structured Outputs
from pydantic import BaseModel
class SentimentResult(BaseModel):
sentiment: Literal["positive", "negative", "neutral"]
confidence: float
reason: str
response = client.beta.chat.completions.parse(
model="gpt-4o-mini",
messages=[{"role": "user", "content": f"Analyze: {text}"}],
response_format=SentimentResult,
)
result: SentimentResult = response.choices[0].message.parsed
# result.sentiment, result.confidence, result.reason — all typed
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 167 lines · 31 tokens per session scan A 534213054da9
openai-patterns is a skill published in the GitHub repository chandrudp29/skillhub (13 stars, last pushed 2mo ago), licensed MIT. It adds 31 tokens to every session and 1,251 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
prompt-optimization
Improve a prompt on the evaluations workbench through a measured loop. Score the baseline first, then duplicate the target column, form a hypothesis from failing rows, edit the copy's prompt draft, run, compare pass rate and cost, and repeat until the numbers hold. Use when the user asks to optimize or improve a…
prompts
Version and manage your agent's prompts with LangWatch Prompts CLI. Use for both onboarding (set up prompt versioning for an entire codebase) and targeted operations (version a specific prompt, create a new prompt version). Supports Python and TypeScript.
how-to-write-component
Use when implementing or refactoring React/TypeScript components and the task requires decisions about component ownership, feature boundaries, state, data flow, effects, or interaction ownership. Do not use for review-only requests, test-only work, copy-only edits, or styling-only changes.
backend-code-review
Use only when the user explicitly requests a review or audit of backend code under api/. Supports pending-change, file-focused, and pasted-diff reviews. Do not use for implementation-only requests, diagnosis without review intent, frontend code, or backend code outside api/.
e2e-cucumber-playwright
Use when writing, changing, or reviewing Cucumber and Playwright tests under e2e/, including feature files, step definitions, support code, scenario tags, locators, and assertions. Do not use for Vitest, React Testing Library, backend tests, or generic browser automation outside the E2E suite.
frontend-code-review
Use only when the user explicitly requests a review or audit of frontend code under web/ or packages/dify-ui/. Supports pending-change, file-focused, and pasted-diff reviews. Do not use for implementation-only requests, diagnosis without review intent, or backend-only code.