log
(response.output_text);
Execute the code with
node example.mjs
(or the equivalent command for Deno or Bun). In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
Python
To use the OpenAI API in Python, you can use the official
OpenAI SDK for Python
. Get started by installing the SDK using
pip
:
Install the OpenAI SDK with pip
1
pip
install
openai
With the OpenAI SDK installed, create a file called
example.py
and copy the example code into it:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
from
openai
import
OpenAI
client
=
OpenAI()
response
=
client.responses.create(
model
=
"gpt-6-astra"
,
input
=
"Write a one-sentence bedtime story about a unicorn."
,
)
print
