Loading video player...
This is Codex SDK, OpenAI's version of
the Clawude agent SDK that makes it easy
to create your own custom agent for
CI/CD pipelines, internal tools, or just
to integrate codecs into your own app.
Pretty cool, right? But with OpenAI
working on so many other things like the
app SDK and the agent builder, have they
given as much love to this powerful
library as Anthropic has to theirs?
Let's find out. And before we do, don't
forget to hit the subscribe button.
The Codeex SDK, not to be confused with
the Codeex CLI, the IDE extension, or
Codeex web, is a TypeScript only
library, sorry, Python, that lets you
programmatically control the Codeex
agent. Here is the most basic example of
the SDK being used. We import the codeex
class that's being initialized here for
interacting with the agent. and I'm
passing in the API key that I've stored
in amp file. From here, we're running
the start thread method to start a
conversation. Then we use the run
function to run this prompt and we print
the results over here. So, if we run the
file, we can see the format of the
response passing in an array of items,
then the final response before the usage
object. Up here, we can see the model is
reasoning before returning a message. If
you wanted to, you could specify the
model and you can set the sandbox mode.
For reference, you can choose between
readon, workspace, write, and danger
full access. For more information on
sandbox modes and approval modes, check
out my video on the codec CLI. But here
we're only giving the agent read only
access to my files. Now, if we run the
index file again, we can see the model
doesn't reason. And this response uses
more input and output tokens than the
previous one. So because of that we'll
stick to codeex. You can also use
multiple run methods to resume the
thread or use the resume thread method
passing in the thread ID or even specify
a response format by using a custom JSON
schema or you can use zod. But you may
have noticed the response comes all at
once instead of streaming in bit by bit.
To fix that, instead of using run, we
can use run streamed, which returns
events. And instead of console logging
the result, we need to use for of with
the await key to loop over each of the
events and we'll console log the full
event. So now if we run the file, we can
see it first starts the thread before
reasoning and then returning the
completed value. Notice each event has a
type and the returned value can be
different. And the second field, so
item, thread ID or usage can have a
different form. We can use that to our
advantage by creating something like an
if statement that will only return the
events we care about. So here is a tool
being used. Here is the agent message
and here is the usage object. In fact,
we don't actually need to return the
rest of the events. So let's delete
this. Now if we run the file, we just
get the agent message and the usage.
Let's update the prompt to see tool
usage. And after running the file again,
we can see the command that was used
before the agent sent a message. But
just like the example used in my Claude
agents SDK video, we can make this more
interactive by letting the user add an
input then processing that input before
letting the user add a follow-up prompt.
So now running the file, I get this nice
message. I can give it a prompt like how
many files are in this project excluding
node modules. Then the agent thinks,
uses a tool call, gives the response,
tells me the usage, and lets me
continue. I can then ask a follow-up
question like, "What's the loc of
index.ts?" And then I get another
response. And that's a quick overview of
the codeex SDK. It's nice and simple,
but for me, it's missing a few features
like being able to see the selected
model in the output, being able to
change the system prompt and support for
custom tools, hooks, custom slash
commands, the list goes on. So, because
of that, I'll be sticking with the
clawed agents SDK, but I'll keep an eye
on this project to see if it gets better
in the future. Then again, if you wanted
to build a more complicated agent, you'd
use OpenAI's agent builder, which you
can learn all about from this video by
James
The Codex SDK lets you use OpenAI's Codex model easily. It has a simple way to start and run programs, great streaming with a special runStreamed feature, and flexible settings for developers. Codex is easy to use, but Anthropic's Claude SDK is better at organizing tasks and thinking deeply. This comparison explains how hard they are to use, how fast they work, and how they help in real projects. 🔗 Relevant Links Codex CLI - https://www.youtube.com/watch?v=Szi4SHB4nNs OpenAI Agent Builder - https://www.youtube.com/watch?v=RBlHcHUvFKY ❤️ More about us Radically better observability stack: https://betterstack.com/ Written tutorials: https://betterstack.com/community/ Example projects: https://github.com/BetterStackHQ 📱 Socials Twitter: https://twitter.com/betterstackhq Instagram: https://www.instagram.com/betterstackhq/ TikTok: https://www.tiktok.com/@betterstack LinkedIn: https://www.linkedin.com/company/betterstack