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 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/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/chandrudp29/skillhub/openai-patterns"><img src="https://agentmods.dev/badge/skills/chandrudp29/skillhub/openai-patterns.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00031 | $0.01251 |
| Opus 5.5 | $0.00012 | $0.00500 |
| Sonnet 5.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 1mo 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.
- 1mo ago First seen · 167 lines · 31 tokens per session scan A 534213054da9
openai-patterns is a skill published in the GitHub repository chandrudp29/skillhub (14 stars, last pushed 3mo ago), licensed MIT. It adds 31 tokens to every session and 1,251 once invoked, about $0.0001 per session on Opus 5.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
liter-llm-tool-calling
Use when defining functions/tools for an LLM to call through liter-llm, or requesting structured JSON outputs. Covers tool schemas, toolcalls handling, and response formats.
c-ai
Query LLMs from the CLI — pipe text for summarization, chat interactively, use local or cloud models with llm or aichat.
pydantic-ai
Build production-ready AI agents with PydanticAI — type-safe tool use, structured outputs, dependency injection, and multi-model support.
dspy
DSPy: declarative LM programs, auto-optimize prompts, RAG.
outlines
Outlines: structured JSON/regex/Pydantic LLM generation.
instructor
Structured LLM outputs validated with Pydantic.