askill
openai-llm

openai-llmSafety 90Repository

Invoke OpenAI models for text generation, reasoning, and code tasks using the Python openai SDK. Supports gpt-4o (multimodal), o1 (reasoning), o3-mini (fast reasoning), and gpt-4o-mini (fast).

0 stars
1.2k downloads
Updated 2/5/2026

Package Files

Loading files...
SKILL.md

OpenAI LLM Skill

Invoke OpenAI models for text generation, reasoning, code analysis, and complex tasks using the Python openai SDK.

Available Models

Model IDDescriptionBest For
gpt-4oFlagship multimodal modelGeneral tasks, vision, analysis
gpt-4o-miniFast and cost-efficientQuick tasks, high throughput
o1Advanced reasoning modelComplex reasoning, math, code
o1-miniFast reasoningModerate reasoning tasks
o3-miniNewest reasoning modelDeep reasoning, planning

Configuration

API Key Location: C:\Users\USERNAME\env (OPENAI_API_KEY)

Default API Key: Use environment variable OPENAI_API_KEY

Usage

Basic Text Generation

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{'role': 'user', 'content': 'YOUR_PROMPT_HERE'}]
)
print(response.choices[0].message.content)
"

With System Instructions

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[
        {'role': 'system', 'content': 'You are a helpful coding assistant.'},
        {'role': 'user', 'content': 'YOUR_PROMPT_HERE'}
    ],
    temperature=0.7,
    max_tokens=4096
)
print(response.choices[0].message.content)
"

Streaming Response

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
stream = client.chat.completions.create(
    model='gpt-4o',
    messages=[{'role': 'user', 'content': 'YOUR_PROMPT_HERE'}],
    stream=True
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end='', flush=True)
print()
"

Using Reasoning Models (o1, o3-mini)

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='o1',
    messages=[{'role': 'user', 'content': 'YOUR_COMPLEX_REASONING_PROMPT'}]
)
print(response.choices[0].message.content)
"

Workflow

When this skill is invoked:

  1. Parse the user request to determine:

    • The prompt/task to send to OpenAI
    • Which model to use (default: gpt-4o)
    • Any configuration options (temperature, max tokens, system message)
  2. Select the appropriate model:

    • General tasks/analysis → gpt-4o
    • Quick responses → gpt-4o-mini
    • Complex reasoning/math → o1 or o3-mini
    • Moderate reasoning → o1-mini
  3. Execute the Python command using Bash tool:

    python -c "
    from openai import OpenAI
    client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
    response = client.chat.completions.create(
        model='MODEL_ID',
        messages=[{'role': 'user', 'content': '''PROMPT'''}]
    )
    print(response.choices[0].message.content)
    "
    
  4. Return the response to the user

Example Invocations

Code Review

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{'role': 'user', 'content': '''Review this Python code for bugs and improvements:

def calculate_total(items):
    total = 0
    for item in items:
        total += item.price * item.quantity
    return total
'''}]
)
print(response.choices[0].message.content)
"

Complex Reasoning (with o1)

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='o1',
    messages=[{'role': 'user', 'content': 'Solve this step by step: A farmer has 17 sheep. All but 9 die. How many are left?'}]
)
print(response.choices[0].message.content)
"

Generate Code

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[
        {'role': 'system', 'content': 'You are an expert Python developer. Write clean, efficient, well-documented code.'},
        {'role': 'user', 'content': 'Write a Python function to merge two sorted lists'}
    ],
    temperature=0.3
)
print(response.choices[0].message.content)
"

Multi-turn Conversations

For conversations with history:

python -c "
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[
        {'role': 'user', 'content': 'What is Python?'},
        {'role': 'assistant', 'content': 'Python is a high-level programming language...'},
        {'role': 'user', 'content': 'How do I install it?'}
    ]
)
print(response.choices[0].message.content)
"

Model Notes

Reasoning Models (o1, o3-mini)

  • Do NOT support system messages - use user messages only
  • Do NOT support temperature parameter
  • May take longer to respond (they "think" internally)
  • Best for math, logic, complex code problems

GPT-4o Models

  • Support system messages and all parameters
  • Fast responses
  • Good for general tasks, vision, multimodal

Error Handling

The skill handles common errors:

  • Rate Limiting: Wait and retry with exponential backoff
  • Token Limits: Truncate input or use streaming for large outputs
  • Invalid Model: Fall back to gpt-4o

Tools to Use

  • Bash: Execute Python commands
  • Read: Load files to include in prompts
  • Write: Save OpenAI responses to files

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

88/100Analyzed 2/12/2026

A comprehensive and well-structured skill for OpenAI API integration, featuring model comparisons, specific usage patterns for reasoning models, and clear workflow steps.

90
95
90
95
80

Metadata

Licenseunknown
Version-
Updated2/5/2026
Publisherrdfitted

Tags

apigithub-actionsllmprompting