<<<<<<< codex/fix-fetch-request-error-qv346p A minimal Flask API that answers math questions using OpenAI Responses API with code interpreter.
A minimal Flask API that answers questions using an OpenAI agent-style workflow with tools enabled:
- Web search (
web_search) - Code interpreter (
code_interpreter)
main
GET /→ healthcheck ({"status":"ok"})GET /hello?name=Alice→ returns{"message":"Hello Alice"}POST /ask→ asks the agent a question
Example request:
curl -X POST http://localhost:5000/ask \
-H "Content-Type: application/json" \
-d '{"question": "Find the latest Python release and compare 2^10 vs 10^2"}'Example response:
{
"answer": "...",
<<<<<<< codex/fix-fetch-request-error-qv346p
"model": "gpt-4.1"
=======
"model": "gpt-5-mini"
>>>>>>> main
}If question is missing/empty, API returns HTTP 400.
OPENAI_API_KEY(required) — your OpenAI API key. <<<<<<< codex/fix-fetch-request-error-qv346pOPENAI_MODEL(optional) — defaults togpt-4.1.- Uses OpenAI Responses API with
code_interpreterconfigured withcontainer: {"type": "auto", "memory_limit": "4g"}(requires modernopenaiSDK). ======= OPENAI_MODEL(optional) — defaults togpt-5-mini.- Uses OpenAI Responses API with
web_searchandcode_interpretertools (requires modernopenaiSDK).
main
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export OPENAI_API_KEY="your_api_key_here"
# optional:
<<<<<<< codex/fix-fetch-request-error-qv346p
# export OPENAI_MODEL="gpt-4.1"
=======
# export OPENAI_MODEL="gpt-5-mini"
>>>>>>> main
python app.pyThis repository includes render.yaml, so the easiest option is Render Blueprint deploy:
- Push this repo to GitHub.
- In Render, click New + → Blueprint.
- Select your repository.
- Add
OPENAI_API_KEYin the Render service environment variables. - Deploy.