Free, Unlimited Codex API
On this page
In this tutorial, you will learn how to add Codex models into your application for free using Puter.js. You can gain access to models such as GPT-5.1-Codex-Max, GPT-5.1-Codex, and GPT-5.1-Codex-Mini by OpenAI without needing an OpenAI developer account or API key.
Puter.js uses the User-Pays model, where users of your application cover their own AI costs. This means you as a developer don't pay anything for your users' usage, making your app practically free to run. You can scale to unlimited users and pay nothing for the AI or server usage.
Getting Started
Add Puter.js to your project with a single line:
<script src="https://js.puter.com/v2/"></script>
That's it, you're ready to start integrating Codex into your application.
Example 1: Basic code generation
Codex excels at code generation tasks. Here's how to use it for writing code:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"Write a Python function that implements binary search on a sorted array",
{ model: "openrouter:openai/gpt-5.1-codex" }
)
.then(response => {
puter.print(response, {code: true});
});
</script>
</body>
</html>
Example 2: Maximum performance with Codex Max
For the most demanding coding tasks, use GPT-5.1-Codex-Max:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"Write a Python function that implements binary search on a sorted array",
{ model: "openrouter:openai/gpt-5.1-codex-max" }
)
.then(response => {
puter.print(response, {code: true});
});
</script>
</body>
</html>
Example 3: Efficient code generation with Codex Mini
For faster responses on simpler tasks, use GPT-5.1-Codex-Mini:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"Write a Python function that implements binary search on a sorted array",
{ model: "openrouter:openai/gpt-5.1-codex-mini" }
)
.then(response => {
puter.print(response, {code: true});
});
</script>
</body>
</html>
List of Codex models
You can use the following Codex model variants with Puter.js:
openrouter:openai/codex-mini
openrouter:openai/gpt-5-codex
openrouter:openai/gpt-5.1-codex
openrouter:openai/gpt-5.1-codex-max
openrouter:openai/gpt-5.1-codex-mini
Conclusion
Using Puter.js, you can gain access to Codex models without needing an OpenAI developer account or API key. And thanks to the User-Pays model, your users cover their own AI usage, not you as the developer. This means you can build powerful applications without worrying about AI usage costs.
You can find all AI features supported by Puter.js in the documentation.
Related
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now