Pre-flight checklist
- This is about the Perplexity API, not the Perplexity app, Comet, or web UI.
- I have removed API keys, secrets, and private data.
- I have included enough information for someone else to reproduce the issue.
Bug type
- Error response or failed request
- Incorrect or unexpected model output
- Missing, invalid, or stale citations/search results
- Streaming issue
- Structured output or JSON schema issue
- SDK issue
- Billing, credits, or rate limit issue
- Dashboard, API key, or auth issue
- Other API bug
Affected API area
- Agent API
- Search API
- Sonar API
- Embeddings API
- SDKs
- Dashboard, API keys, or auth
- Billing or credits
- Not sure
Summary
The newest Gemini models (3.5 flash lite and 3.6 flash) there is something wrong when using web search tool calls in the API. See https://gist.github.com/apwheele/0fb00fc9749ecdfd52c833f9fc97eee3 for reproducible script.
Expected behavior
The script shows tool calling in the responses API works with the older models. Just the newest released model does not work. Also see https://x.com/CrimeDecoder/status/2080979274291462471 for some screenshots of this in the API console where you can just use the GUI.
Actual behavior
Returns a 400 error
Minimal reproduction
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PERPLEXITY_API_KEY"],
base_url="https://api.perplexity.ai/v1",
)
prompt = """What does
https://andrewpwheeler.com/2026/07/23/notes-on-document-processing-with-llms/
talk about?"""
# works
response = client.responses.create(
model="google/gemini-3.1-flash-lite",
input=prompt,
tools=[{"type": "web_search"}],
)
print(response.output_text)
# fails
response = client.responses.create(
model="google/gemini-3.5-flash-lite",
input=prompt,
tools=[{"type": "web_search"}],
)
print(response.output_text)
Response or error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/apwheele/miniconda3/lib/python3.12/site-packages/openai/_base_client.py", line 1105, in request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'invalid request', 'type': 'invalid_request', 'code': 400}}
Request details
- Endpoint: responses endpoint
- Model or preset: gemini 3.5 flash lite and gemini 3.6 flash
- SDK/language/version: python
- Request ID:
- Approximate time and timezone:
- Consistent or intermittent: consistent