External Publication
Visit Post

How do I send a GPT-4 API request from Python?

OpenAI Developer Community March 16, 2026
Source

GPT-4 is an AI model, and you’ll likely want to start with gpt-5-nano for testing (and with a new organization where you have gone through “create building”, you might have minimal free usage before needing to prepay for credits.

Here’s sending a request, and the rest of API support for “build a simple AI chatbot” - by way of searching the forum.

I am getting an error while using code interpreter in Response Api

If you still want to go at it, here’s some console Python chat code for you. It uses the previous response ID method and non-streaming simply because the alternate is massive event code and custom database, and supports nothing other than code interpreter. I just tacked the tool and support onto other example code I had open.

  • A container ID is created but no other management of the lifecycle.
  • Any files created that the AI cites for you will automatically be downloaded to a code-files sub-directory.
  • There is a function to upload, but no interface to upload. You could hard-code a list of files to iterate over to upload to the container after it is created.
  • exit, and the response IDs are cleaned from the server (and the container is allowed to expire).

Request for example of a custom tool Function Call back using the client.responses.create() method

"""Console chatbot: Conversations + Custom Tools + Persistent Memory

Demonstrates OpenAI's Responses API with:
- Server-side conversation state
- Custom tools (plain-text inputs/outputs)
- Cross-session memory storage
- Guaranteed cleanup of server-side artifacts

Requirements:
  pip install httpx
  export OPENAI_API_KEY="..."

Run:
  python chatbot_custom_tools_memory.py

Discussion in the ATmosphere

Loading comments...