Repository navigation
Replies: 1 comment
|
There's no official Python SDK for Codex CLI yet, but you have two solid options right now: Option 1 — Use the OpenAI Python SDK directly (recommended) The same models powering Codex are accessible via the OpenAI Python SDK: pip install openaifrom openai import OpenAI
client = OpenAI(api_key="your_api_key")
response = client.chat.completions.create(
model="o4-mini",
messages=[{"role": "user", "content": "Refactor this function: ..."}]
)
print(response.choices[0].message.content)Option 2 — Call the Codex CLI from Python via subprocess import subprocess
result = subprocess.run(
["codex", "your prompt here"],
capture_output=True, text=True
)
print(result.stdout)A native Python SDK is likely on the roadmap given the demand, but the OpenAI Python SDK is the closest supported path for now. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is there a plan for when you’ll support a Python SDK?
All reactions