Primary navigation
Models

Code generation

Learn how to use OpenAI models and Codex to generate code.

Writing, reviewing, editing, and answering questions about code is one of the primary use cases for OpenAI models today. This guide walks through your options for code generation with gpt-5.6 and Codex.

Get started

Use Codex

Codex is OpenAI’s coding agent for software development. It helps you write, review and debug code. Interact with Codex in a variety of interfaces: in your IDE, through the CLI, on web and mobile sites, or in your CI/CD pipelines with the SDK. Codex is the best way to get agentic software engineering on your projects.

Codex works best with the latest models from the GPT-5 family, such as gpt-5.6. We offer a range of models specifically designed to work with coding agents like Codex, such as gpt-5.3-codex, but we recommend using the latest general-purpose model for most code generation tasks.

See the ChatGPT docs for setup guides, reference material, pricing, and more information.

Integrate with coding models

For most API-based code generation, start with gpt-5.6. It handles both general-purpose work and coding, which makes it a strong default when your application needs to write code, reason about requirements, inspect docs, and handle broader workflows in one place.

This example shows how you can use the Responses API for a code generation use case:

Default model for most coding tasks
python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from openai import OpenAI

client = OpenAI()

result = client.responses.create(
    model="gpt-5.6",
    input="""Find the null pointer exception in this code:

def display_name(user):
    return user.profile.name

print(display_name(None))
""",
    reasoning={"effort": "high"},
)

print(result.output_text)

Frontend development

Our models from the GPT-5 family are especially strong at frontend development, especially when combined with a coding agent harness such as Codex.

The demo applications below were one shot generations, i.e. generated from a single prompt without hand-written code. Use them to evaluate frontend generation quality and prompt patterns for UI-heavy code generation workflows.

Next steps

  • Visit the ChatGPT docs to learn what you can do with Codex, set up Codex in whichever interface you choose, or find more details.
  • Read Model guidance for model selection, features, migration guidance, and prompting patterns that work well on coding and agentic tasks.
  • Compare gpt-5.6 and gpt-5.3-codex on the model pages.

Docs agent

Loading docs agent...

Morty Proxy This is a proxified and sanitized view of the page, visit original site.