OpenAI API Quickstart
Use one small Responses request to verify the intended server-side integration before adding tools, streaming or application state.
#Prepare the environment
Install the official SDK and configure OPENAI_API_KEY securely. Set OPENAI_MODEL to a model ID available to the intended project; do not guess one from a marketing name.
bashpip install openai
#Python
pythonimport os from openai import OpenAI client = OpenAI(timeout=20.0) response = client.responses.create( model=os.environ["OPENAI_MODEL"], input="Explain a Python generator in two sentences.", ) print(response.output_text)
#JavaScript
javascriptimport OpenAI from "openai"; const client = new OpenAI({ timeout: 20000 }); const response = await client.responses.create({ model: process.env.OPENAI_MODEL, input: "Explain a Python generator in two sentences." }); console.log(response.output_text);
These are provider examples that require account authorization and may incur usage charges; they are not offline fixtures.
#Verify the minimum path
Confirm the correct project/key, a successful response and usable output. Record request identifiers and safe diagnostic metadata, while excluding secrets and sensitive prompt content from ordinary logs.
Do not begin with a complex agent or put the key in frontend code. Once the minimal request is understood, add the next capability with its own acceptance checks.