From c5fee97850d43ddfdb2c724d9c932eadd6a6fbe5 Mon Sep 17 00:00:00 2001 From: mubashirosmani Date: Thu, 23 Oct 2025 21:25:59 -0400 Subject: [PATCH] docs: add OpenAI responses api (#15868) * docs: add tip openai page * added responses api --------- Co-authored-by: mubashir1osmani --- docs/my-website/src/pages/index.md | 115 +++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/docs/my-website/src/pages/index.md b/docs/my-website/src/pages/index.md index 2c89d28a62..1dc2995c5f 100644 --- a/docs/my-website/src/pages/index.md +++ b/docs/my-website/src/pages/index.md @@ -214,6 +214,92 @@ response = completion( +### Responses API + +Use `litellm.responses()` for advanced models that support reasoning content like GPT-5, o3, etc. + + + + +```python +from litellm import responses +import os + +## set ENV variables +os.environ["OPENAI_API_KEY"] = "your-api-key" + +response = responses( + model="gpt-5-mini", + messages=[{ "content": "What is the capital of France?","role": "user"}], + reasoning_effort="medium" +) + +print(response) +print(response.choices[0].message.content) # response +print(response.choices[0].message.reasoning_content) # reasoning + +``` + + + + +```python +from litellm import responses +import os + +## set ENV variables +os.environ["ANTHROPIC_API_KEY"] = "your-api-key" + +response = responses( + model="claude-3.5-sonnet", + messages=[{ "content": "What is the capital of France?","role": "user"}] +) +``` + + + + + +```python +from litellm import responses +import os + +# auth: run 'gcloud auth application-default' +os.environ["VERTEX_PROJECT"] = "jr-smith-386718" +os.environ["VERTEX_LOCATION"] = "us-central1" + +response = responses( + model="chat-bison", + messages=[{ "content": "What is the capital of France?","role": "user"}] +) +``` + + + + + +```python +from litellm import responses +import os + +## set ENV variables +os.environ["AZURE_API_KEY"] = "" +os.environ["AZURE_API_BASE"] = "" +os.environ["AZURE_API_VERSION"] = "" + +# azure call +response = responses( + "azure/", + messages = [{ "content": "What is the capital of France?","role": "user"}] +) + +print(response) +``` + + + + + ### Streaming Set `stream=True` in the `completion` args. @@ -504,6 +590,10 @@ model_list: api_base: os.environ/AZURE_API_BASE # runs os.getenv("AZURE_API_BASE") api_key: os.environ/AZURE_API_KEY # runs os.getenv("AZURE_API_KEY") api_version: "2023-07-01-preview" + +litellm_settings: + master_key: sk-1234 + database_url: postgres:// ``` ### Step 2. RUN Docker Image @@ -524,6 +614,9 @@ docker run \ #### Step 2: Make ChatCompletions Request to Proxy + + + ```python import openai # openai v1.0.0+ client = openai.OpenAI(api_key="anything",base_url="http://0.0.0.0:4000") # set proxy to base_url @@ -538,6 +631,28 @@ response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [ print(response) ``` + + + +```python +from openai import OpenAI + +client = OpenAI( + api_key="sk-1234", + base_url="http://0.0.0.0:4000" +) + +response = client.responses.create( + model="gpt-5", + input="Tell me a three sentence bedtime story about a unicorn." +) + +print(response) +``` + + + + ## More details - [exception mapping](../../docs/exception_mapping)