Skip to main content
1

Add the SDK

Check out Codex Typescript SDK on GitHub or just get right into installation:
2

Add the API key to your environment variables

Usually these live in your .env file. Add this line and replace xxxxxxxx with your API key:
3

Create an SDK file

Make a new lib/codex-sdk.ts file (or whatever folder/name fits your project) and add:
4

Make a request

Now you can import the SDK from other files and make requests. For example:
5

See more examples

Check out Codex Typescript SDK GitHub for examples of:
  • Next.js integation
  • Codegen
  • Subscriptions
  • Short-lived API keys
  • Writing custom GraphQL queries (in which case you may want to read Using the GraphQL API)
  • And more