Skip to content

feat(fireworks_ai): add native Responses API config - #39826

Merged
mateo-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_lit_6348_fireworks_responses_api
Sep 7, 2026
Merged

mateo-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_lit_6348_fireworks_responses_api

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • /v1/responses calls for fireworks_ai/ models were bridged through chat completions
  • Fireworks rejects the bridge's request the moment a type: "mcp" tool is attached
  • Fireworks' own Responses API (server-side MCP, previous_response_id) was unreachable through LiteLLM

How it solves it:

  • Adds FireworksAIResponsesAPIConfig, routing fireworks_ai/ models to https://api.fireworks.ai/inference/v1/responses
  • Bare names expand to accounts/fireworks/models/<name>, x-session-affinity carries the caller's session id
  • Shares the API key and session helpers with the chat path
  • Maps Fireworks' {"message": "Response deleted successfully"} delete body onto the standard {id, object, deleted} result
  • Sends developer input items as system messages, because Fireworks' Responses API rejected the developer role on kimi-k3 and qwen3.8 when this was built (a534b9f)
  • Runs that mapping after the shared input validation dumps pydantic items, so SDK-typed inputs get it too (e9a40ad)
  • Keeps file_search tools on LiteLLM's emulated file search, the way the bridge ran them, because Fireworks' Responses API accepts the tool and silently skips the search (0157808)

User Flow

Before: a developer whose agent app calls the gateway with the OpenAI SDK's client.responses.create on a Fireworks model gets a 400 the moment it attaches an MCP tool, because the request is rewritten into a chat completion that Fireworks rejects

  1. The proxy admin adds fireworks_ai/accounts/fireworks/models/kimi-k3 to the model list as fireworks-kimi-k3 and restarts the proxy
  2. The developer sends POST https://litellm-domain/v1/responses with "model": "fireworks-kimi-k3", an input string, and a get_weather function tool
  3. 200 comes back with output items reasoning, message, function_call, the function call carrying call_id get_weather_0
  4. They send POST https://litellm-domain/v1/responses with previous_response_id set to that response's id and a function_call_output item for the call
  5. 200 comes back with a message reading out the weather
  6. They send POST https://litellm-domain/v1/responses with the same model and a {"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never"} tool
  7. 400 comes back: Fireworks_aiException - ... Input should be 'function', 'web_search_preview' or 'code_interpreter', field: 'tools[0].type', value: 'mcp'; Extra inputs are not permitted, field: 'tools[0].server_label' ...

After: the same requests go to Fireworks' own Responses endpoint, so the MCP tool runs server-side and the app gets its answer

  1. The proxy admin adds fireworks_ai/accounts/fireworks/models/kimi-k3 to the model list as fireworks-kimi-k3 and restarts the proxy
  2. The developer sends POST https://litellm-domain/v1/responses with "model": "fireworks-kimi-k3", an input string, and a get_weather function tool
  3. 200 comes back with output items including reasoning and function_call (call_id get_weather_0), and the response id is Fireworks' own resp_...
  4. They send POST https://litellm-domain/v1/responses with previous_response_id set to that response's id and a function_call_output item for the call
  5. 200 comes back with a message reading out the weather
  6. They send POST https://litellm-domain/v1/responses with the same model and a {"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never"} tool
  7. 200 comes back with output items reasoning, mcp_call, tool_output, message, the message being the one-sentence answer Fireworks produced after running the MCP call itself

Relevant issues

Linear ticket

Resolves LIT-6348

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Both legs: a proxy started with --num_workers 2, no database, model entries fireworks-kimi-k3 -> fireworks_ai/accounts/fireworks/models/kimi-k3, fireworks-qwen3p8 -> fireworks_ai/accounts/fireworks/models/qwen3p8-2p4t-a95b, and fireworks-glm-5p3 -> fireworks_ai/accounts/fireworks/models/glm-5p3, each with api_key: os.environ/FIREWORKS_API_KEY, master key sk-lit6348, real Fireworks API, openai SDK 2.33.0. Cases A to C are one Python script run against each proxy, taking the port as its argument. Before is the merge base 3868364 on port 24353, after is the PR tip 18aa52d (the branch merged with litellm_internal_staging at 3868364) on port 51035. The model is nondeterministic about calling the tool: on each leg the first run of the script skipped one tool call (case B on the before leg answered with an empty message, case A on the after leg answered without a function_call) and the second run, shown here, called it

Before (3868364)

Cases A to C: function tool, previous_response_id with a function_call_output, MCP tool, all via the OpenAI SDK

  1. Command (.venv/bin/python sdk_cases.py 24353, the worktree's venv)
import sys

from openai import OpenAI

port = sys.argv[1]
client = OpenAI(base_url=f"http://localhost:{port}", api_key="sk-lit6348")

print("=== Case A function tool via the OpenAI SDK ===")
resp = client.responses.create(
    model="fireworks-kimi-k3",
    input="What is the weather in Paris? Use the get_weather tool.",
    tools=[{
        "type": "function",
        "name": "get_weather",
        "description": "Get the current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    }],
)
print("resp.id:", resp.id)
print("output types:", [item.type for item in resp.output])
function_calls = [item for item in resp.output if item.type == "function_call"]
for item in function_calls:
    print("function_call.name:", item.name)
    print("function_call.arguments:", item.arguments)
    print("function_call.call_id:", item.call_id)

print("=== Case B previous_response_id with a function_call_output ===")
resp2 = client.responses.create(
    model="fireworks-kimi-k3",
    previous_response_id=resp.id,
    input=[{
        "type": "function_call_output",
        "call_id": function_calls[0].call_id,
        "output": "22C and sunny",
    }],
)
print("output types:", [item.type for item in resp2.output])
print("output_text:", resp2.output_text)

print("=== Case C MCP tool via the OpenAI SDK ===")
try:
    resp3 = client.responses.create(
        model="fireworks-kimi-k3",
        input="Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.",
        tools=[{
            "type": "mcp",
            "server_label": "deepwiki",
            "server_url": "https://mcp.deepwiki.com/mcp",
            "require_approval": "never",
        }],
    )
    print("output types:", [item.type for item in resp3.output])
    print("output_text:", resp3.output_text)
except Exception as exc:
    print("EXCEPTION:", type(exc).__name__)
    print(str(exc))
  1. Output
=== Case A function tool via the OpenAI SDK ===
resp.id: resp_FlOHxTi-2rGYmZ6pzJxcy3t0Dcd995lhCqifxZwnRO2Vsag9JtC1KWYmOHud9lgzS9r67lXBfUpC-HfdEdogWCU8ySDBp6DFDYivYUHmU4bLXOec1gkJCihIobFqe4HQO8n-UXri5_rpmACS-rxy4lwoEZEJFkTzEy0tMNDCH7Ze2wUrHh36qJTJHZvBK4pOnLqm01qiFIiPliFys9uYe_01_ckh4zeHzzZZuB6b59whvkYYI3M7ise-Ay67WALmzqKb-vxabwm87W0sMFRB0LXQhot1lbivt_xUTOcytBSvMCeqJR-rUTuKL-1NdFO-bHgnmfXxHSk8WWouPn5FyzuP5CIBQsxBgxyxN8ISDowiRU5nMLwlRolQoFgjJgML7_HEYPh5sy2fuZ-EvezN3LynYBgoZC6YYE3hpCXqMy-nOqwOOHB7EVlZUukKGh2zCPyGJ1TP
output types: ['reasoning', 'message', 'function_call']
function_call.name: get_weather
function_call.arguments: {"city": "Paris"}
function_call.call_id: get_weather_0
=== Case B previous_response_id with a function_call_output ===
output types: ['reasoning', 'message']
output_text: The weather in Paris is currently **22°C and sunny** — a lovely day! ☀️

Let me know if you'd like the weather for any other city.
=== Case C MCP tool via the OpenAI SDK ===
EXCEPTION: BadRequestError
Error code: 400 - {'error': {'message': 'litellm.BadRequestError: Fireworks_aiException - {"error":{"object":"error","type":"invalid_request_error","code":"invalid_request_error","message":"4 request validation errors: Input should be \'function\', \'web_search_preview\' or \'code_interpreter\', field: \'tools[0].type\', value: \'mcp\'; Extra inputs are not permitted, field: \'tools[0].server_label\', value: \'deepwiki\'; Extra inputs are not permitted, field: \'tools[0].server_url\', value: \'https://mcp.deepwiki.com/mcp\'; Extra inputs are not permitted, field: \'tools[0].require_approval\', value: \'never\'"}}. Received Model Group=fireworks-kimi-k3\nAvailable Model Group Fallbacks=None', 'type': 'invalid_request_error', 'param': None, 'code': '400'}}

Case D: MCP tool via curl with response headers

  1. Command (zsh case_d.sh 24353: the first line saves the raw response, the next three print the status line, the two headers of interest, and the trimmed body)
port=$1
out=${2:-case_d.raw}
curl -sS -i "http://localhost:${port}/v1/responses" -H 'Authorization: Bearer sk-lit6348' -H 'Content-Type: application/json' -d '{"model":"fireworks-kimi-k3","input":"Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.","tools":[{"type":"mcp","server_label":"deepwiki","server_url":"https://mcp.deepwiki.com/mcp","require_approval":"never"}]}' > "$out"
head -1 "$out"
grep -iE '^(x-litellm-model-api-base|x-litellm-response-cost):' "$out"
python3 -c 'import json,sys; raw=open(sys.argv[1],"rb").read(); body=raw.split(b"\r\n\r\n",1)[1]; r=json.loads(body); print("status:", r.get("status")) if "output" in r else print("body:", body.decode()[:600]); print("output item types:", [o["type"] for o in r["output"]]) if "output" in r else None; print("final text:", "".join(c.get("text","") for o in r["output"] if o["type"]=="message" for c in o.get("content",[]) if c.get("type")=="output_text")) if "output" in r else None' "$out"
  1. Output (status line, the one header that came back, the body; no x-litellm-model-api-base header on this response)
HTTP/1.1 400 Bad Request
x-litellm-response-cost: 0
body: {"error":{"message":"litellm.BadRequestError: Fireworks_aiException - {\"error\":{\"object\":\"error\",\"type\":\"invalid_request_error\",\"code\":\"invalid_request_error\",\"message\":\"4 request validation errors: Input should be 'function', 'web_search_preview' or 'code_interpreter', field: 'tools[0].type', value: 'mcp'; Extra inputs are not permitted, field: 'tools[0].server_label', value: 'deepwiki'; Extra inputs are not permitted, field: 'tools[0].server_url', value: 'https://mcp.deepwiki.com/mcp'; Extra inputs are not permitted, field: 'tools[0].require_approval', value: 'never'\"}}. Re

Case E: MCP tool streamed via curl

  1. Command (zsh case_e.sh 24353)
port=$1
curl -sS -N "http://localhost:${port}/v1/responses" -H 'Authorization: Bearer sk-lit6348' -H 'Content-Type: application/json' -d '{"model":"fireworks-kimi-k3","input":"Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.","tools":[{"type":"mcp","server_label":"deepwiki","server_url":"https://mcp.deepwiki.com/mcp","require_approval":"never"}],"stream":true}' | head -c 1500
  1. Output (the whole response was 734 bytes, so nothing was cut)
{"error":{"message":"litellm.BadRequestError: Fireworks_aiException - {\"error\":{\"object\":\"error\",\"type\":\"invalid_request_error\",\"code\":\"invalid_request_error\",\"message\":\"4 request validation errors: Input should be 'function', 'web_search_preview' or 'code_interpreter', field: 'tools[0].type', value: 'mcp'; Extra inputs are not permitted, field: 'tools[0].server_label', value: 'deepwiki'; Extra inputs are not permitted, field: 'tools[0].server_url', value: 'https://mcp.deepwiki.com/mcp'; Extra inputs are not permitted, field: 'tools[0].require_approval', value: 'never'\"}}. Received Model Group=fireworks-kimi-k3\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":null,"code":"400"}}

After (18aa52d)

Cases A to C: function tool, previous_response_id with a function_call_output, MCP tool, all via the OpenAI SDK

  1. Command (.venv/bin/python sdk_cases.py 51035, the worktree's venv)
import sys

from openai import OpenAI

port = sys.argv[1]
client = OpenAI(base_url=f"http://localhost:{port}", api_key="sk-lit6348")

print("=== Case A function tool via the OpenAI SDK ===")
resp = client.responses.create(
    model="fireworks-kimi-k3",
    input="What is the weather in Paris? Use the get_weather tool.",
    tools=[{
        "type": "function",
        "name": "get_weather",
        "description": "Get the current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    }],
)
print("resp.id:", resp.id)
print("output types:", [item.type for item in resp.output])
function_calls = [item for item in resp.output if item.type == "function_call"]
for item in function_calls:
    print("function_call.name:", item.name)
    print("function_call.arguments:", item.arguments)
    print("function_call.call_id:", item.call_id)

print("=== Case B previous_response_id with a function_call_output ===")
resp2 = client.responses.create(
    model="fireworks-kimi-k3",
    previous_response_id=resp.id,
    input=[{
        "type": "function_call_output",
        "call_id": function_calls[0].call_id,
        "output": "22C and sunny",
    }],
)
print("output types:", [item.type for item in resp2.output])
print("output_text:", resp2.output_text)

print("=== Case C MCP tool via the OpenAI SDK ===")
try:
    resp3 = client.responses.create(
        model="fireworks-kimi-k3",
        input="Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.",
        tools=[{
            "type": "mcp",
            "server_label": "deepwiki",
            "server_url": "https://mcp.deepwiki.com/mcp",
            "require_approval": "never",
        }],
    )
    print("output types:", [item.type for item in resp3.output])
    print("output_text:", resp3.output_text)
except Exception as exc:
    print("EXCEPTION:", type(exc).__name__)
    print(str(exc))
  1. Output
=== Case A function tool via the OpenAI SDK ===
resp.id: resp_dydrMDAPnD2ZqunU5KUDz0asFxOUB6md0MSz-HgmHrRiFsig-9fkinmCDsOPpOEf2TiNjUTw757NuqgCNFnLV5rHgnkEO7rH70jcM-QPu6pK7txvvHP0vJcVz8Q37ErzwhIjiOwbh0hqZ8Uxn5jZ1kXOCNA8f33ZesG_eswl0La4LfoYCrA95KTYW83t6kfKGJgp24avIbfrdRcetKIg4TGdSWUhXuxqknnUOumibyl9iqmX0IDLdGmgbWMh2PGWQS23Ra7DOeaNCTOBTWd34SoOre7Be66oon238SskB5Az1up5hhLXx1GA6uqs8BcxT4wuFJllLZWyWp7RevakttEkCuasXjrJWkwev4t1DEfsuxgTnLjhh3YOCI9nqi6_9OMt0IuGDWM-DSkFtPTqjCCALiBMmfjvto20zR2L2sA-ChOQVQwhUjvETQXcuzeRAy0=
output types: ['reasoning', 'message', 'function_call']
function_call.name: get_weather
function_call.arguments: {"city": "Paris"}
function_call.call_id: get_weather_0
=== Case B previous_response_id with a function_call_output ===
output types: ['reasoning', 'message']
output_text: The weather in Paris is currently **22°C and sunny** ☀️ — a beautiful day!
=== Case C MCP tool via the OpenAI SDK ===
output types: ['reasoning', 'mcp_call', 'tool_output', 'reasoning', 'message']
output_text: **LiteLLM (BerriAI/litellm)** is a unified LLM gateway that provides an OpenAI-compatible interface to 100+ LLM providers, available both as a Python SDK for direct integration and as a FastAPI-based proxy server with enterprise features like virtual key management, budgeting, spend tracking, and load balancing.

Case D: MCP tool via curl with response headers

  1. Command (zsh case_d.sh 51035: the first line saves the raw response, the next three print the status line, the two headers of interest, and the trimmed body)
port=$1
out=${2:-case_d.raw}
curl -sS -i "http://localhost:${port}/v1/responses" -H 'Authorization: Bearer sk-lit6348' -H 'Content-Type: application/json' -d '{"model":"fireworks-kimi-k3","input":"Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.","tools":[{"type":"mcp","server_label":"deepwiki","server_url":"https://mcp.deepwiki.com/mcp","require_approval":"never"}]}' > "$out"
head -1 "$out"
grep -iE '^(x-litellm-model-api-base|x-litellm-response-cost):' "$out"
python3 -c 'import json,sys; raw=open(sys.argv[1],"rb").read(); body=raw.split(b"\r\n\r\n",1)[1]; r=json.loads(body); print("status:", r.get("status")) if "output" in r else print("body:", body.decode()[:600]); print("output item types:", [o["type"] for o in r["output"]]) if "output" in r else None; print("final text:", "".join(c.get("text","") for o in r["output"] if o["type"]=="message" for c in o.get("content",[]) if c.get("type")=="output_text")) if "output" in r else None' "$out"
  1. Output (second run; the first run on this leg answered from the model's own knowledge without calling the MCP server, output item types ['reasoning', 'message'])
HTTP/1.1 200 OK
x-litellm-model-api-base: https://api.fireworks.ai/inference/v1
x-litellm-response-cost: 1.857501
status: completed
output item types: ['reasoning', 'message', 'mcp_call', 'tool_output', 'reasoning', 'message']
final text: I'll look up the BerriAI/litellm repository using the deepwiki tools.Based on the deepwiki documentation, **BerriAI/litellm is a unified LLM gateway that provides an OpenAI-compatible interface to 100+ LLM providers, available both as a Python SDK for direct integration and as a FastAPI-based proxy server with enterprise features like authentication, budgeting, and spend tracking.**

Case E: MCP tool streamed via curl

  1. Command (zsh case_e.sh 51035)
port=$1
curl -sS -N "http://localhost:${port}/v1/responses" -H 'Authorization: Bearer sk-lit6348' -H 'Content-Type: application/json' -d '{"model":"fireworks-kimi-k3","input":"Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.","tools":[{"type":"mcp","server_label":"deepwiki","server_url":"https://mcp.deepwiki.com/mcp","require_approval":"never"}],"stream":true}' | head -c 1500
  1. Output (first 1500 bytes of the SSE stream)
data: {"type":"response.created","response":{"id":"resp_Taa_tfkAKWRPiT6IiTtwO_ECa0xAKuzJErfcrh9eOAEUKxM2PQHI2FlUKeOk779zfoVj6AdLEb43k4db92iftzql0uEuJbyDEQe7E32YKJn_j9dU9Y7GBL1tFzTgYaf9Yy-Nz_HpActgfKEmDOIZnY0NffQ72vf6UrHpd0EcSbUm335hIpdVvuMIFGuc_j7PC307J35FjGwBxr5wpd9IPZBZuZqZ7JtH_e-FT_SNNNJQ-nj4GPKO5u3MRkMOazVh3mTSbr-QGWeKr_IaIMDUOqsb0v2uYshLc9iO2PWzwweRf7kPT1LM8_GP8iiS23nN4lTZhbc9Jx-CLAxxvqiM3pPfteB2Sq-wj05uOsxxbxLx6g9O9i4RE9KNfSyOVrINN9jrgUKolHLYiC8dsHyJNQFPBvolX_46nhHPVCdbrykajU_iL3FkXr9eoYVHo_mLeIk=","created_at":1788821419,"metadata":{},"model":"accounts/fireworks/models/kimi-k3","object":"response","output":[],"parallel_tool_calls":true,"temperature":1.0,"tool_choice":"auto","tools":[{"server_label":"deepwiki","type":"mcp","require_approval":"never","server_url":"https://mcp.deepwiki.com/mcp"}],"top_p":1.0,"status":"in_progress","text":{"format":{"type":"text"}},"truncation":"disabled","store":true},"sequence_number":0,"model":"fireworks-kimi-k3"}

data: {"type":"response.in_progress","response":{"id":"resp_Taa_tfkAKWRPiT6IiTtwO_ECa0xAKuzJErfcrh9eOAEUKxM2PQHI2FlUKeOk779zfoVj6AdLEb43k4db92iftzql0uEuJbyDEQe7E32YKJn_j9dU9Y7GBL1tFzTgYaf9Yy-Nz_HpActgfKEmDOIZnY0NffQ72vf6UrHpd0EcSbUm335hIpdVvuMIFGuc_j7PC307J35FjGwBxr5wpd9IPZBZuZqZ7JtH_e-FT_SNNNJQ-nj4GPKO5u3MRkMOazVh3mTSbr-QGWeKr_IaIMDUOqsb0v2uYshLc9iO2PWzwweRf7kPT1LM8_GP8iiS23nN4lTZhbc9Jx-CLAxxvqiM3pPfteB2Sq-wj05uOsxxbxLx6g9O9i4RE9KNfSyOVrINN9jrgUKolHLYiC8dsHyJNQFPBvolX_46nhHPVCdbrykajU_iL3FkXr9eoYVHo_mLeIk=","created_at":1788curl: (23) Failure writing output to destination, passed 217 returned 4294967295

Observations:

  • Before: Fireworks 400 rejects the mcp tool type outright
  • After: MCP runs server-side, mcp_call and tool_output items appear
  • Function call_id is get_weather_0 on both legs
  • After: x-litellm-response-cost populated on the MCP call
  • After: SSE stream opens with response.created and response.in_progress
  • Response ids are Fireworks' own resp_... values, wrapped
  • Case D cost tracks the deepwiki tool output size, which Fireworks bills as input tokens: 1.857501 here on a 2.36 MB tool output (617,898 input tokens), 1.858677 on the d98cc29 run, 0.008793 on the 1fef5d1 run when the server returned a short answer

Verdict: PASS. Cases A and B succeed on both legs, and cases C, D, and E fail with the Fireworks 400 on the before leg and succeed on the after leg

Customer samples, before and after

The partner relayed the customer's failing inputs from a Codex CLI agent loop (LiteLLM 1.96.2, chat completions bridge): a tool result after an empty assistant message (kimi-k3), a developer message after the first input item (qwen3.8), and a namespace-grouped tool next to its flat twin (kimi-k3 and glm-5.3). One script, samples_cases.py <port>, posts each to /v1/responses on the same two proxies as above (merge base 3868364 on port 24353, PR tip 18aa52d on port 51035)

Before (3868364)

=== Case 1 tool result after an empty assistant message (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "tools": [{"type": "function", "name": "exec_command", "description": "Run a shell command", "parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}, "required": ["cmd"]}}], "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Run: echo TOOLS_OK"}]}, {"type": "function_call", "call_id": "exec_command_0", "name": "exec_command", "arguments": "{\"cmd\":\"echo TOOLS_OK\"}"}, {"type": "message", "role": "assistant", "content": [{"type": "text", "text": ""}]}, {"type": "function_call_output", "call_id": "exec_command_0", "output": "TOOLS_OK"}]}
HTTP 200
output types: ['reasoning', 'message']
output_text: Command executed successfully. Output:

```
TOOLS_OK
```

=== Case 2 developer message after the first input item (qwen3p8-2p4t-a95b) ===
request: {"model": "fireworks-qwen3p8", "instructions": "You are a terse assistant.", "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello"}]}, {"type": "message", "role": "developer", "content": [{"type": "input_text", "text": "Answer in five words or fewer."}]}, {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "What is 2+2?"}]}]}
HTTP 400
{"error": {"message": "litellm.BadRequestError: Fireworks_aiException - {\"error\":{\"object\":\"error\",\"type\":\"invalid_request_error\",\"code\":\"invalid_request_error\",\"message\":\"jinja template rendering failed. System message must be at the beginning.\"}}. Received Model Group=fireworks-qwen3p8\nAvailable Model Group Fallbacks=None", "type": "invalid_request_error", "param": null, "code": "400"}}

=== Case 2b developer message after the first input item (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "instructions": "You are a terse assistant.", "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello"}]}, {"type": "message", "role": "developer", "content": [{"type": "input_text", "text": "Answer in five words or fewer."}]}, {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "What is the capital of France?"}]}]}
HTTP 200
output types: ['reasoning', 'message']
output_text: Paris.

=== Case 3a namespace-grouped tool (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "namespace", "name": "mcp__weather", "description": "Weather tools from an MCP server", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}]}
HTTP 200
output types: ['reasoning', 'message', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

=== Case 3b same tool flat (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}
HTTP 200
output types: ['reasoning', 'message', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: I'll check the weather in Paris for you.

=== Case 3c namespace-grouped tool (glm-5p3) ===
request: {"model": "fireworks-glm-5p3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "namespace", "name": "mcp__weather", "description": "Weather tools from an MCP server", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}]}
HTTP 200
output types: ['reasoning', 'message', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

=== Case 3d same tool flat (glm-5p3) ===
request: {"model": "fireworks-glm-5p3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}
HTTP 200
output types: ['reasoning', 'message', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

After (18aa52d)

=== Case 1 tool result after an empty assistant message (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "tools": [{"type": "function", "name": "exec_command", "description": "Run a shell command", "parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}, "required": ["cmd"]}}], "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Run: echo TOOLS_OK"}]}, {"type": "function_call", "call_id": "exec_command_0", "name": "exec_command", "arguments": "{\"cmd\":\"echo TOOLS_OK\"}"}, {"type": "message", "role": "assistant", "content": [{"type": "text", "text": ""}]}, {"type": "function_call_output", "call_id": "exec_command_0", "output": "TOOLS_OK"}]}
HTTP 200
output types: ['message']
output_text: TOOLS_OK

=== Case 2 developer message after the first input item (qwen3p8-2p4t-a95b) ===
request: {"model": "fireworks-qwen3p8", "instructions": "You are a terse assistant.", "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello"}]}, {"type": "message", "role": "developer", "content": [{"type": "input_text", "text": "Answer in five words or fewer."}]}, {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "What is 2+2?"}]}]}
HTTP 400
{"error": {"message": "litellm.BadRequestError: Fireworks_aiException - {\"error\":{\"type\":\"invalid_request_error\",\"code\":\"invalid_request_error\",\"message\":\"jinja template rendering failed. System message must be at the beginning.\"}}. Received Model Group=fireworks-qwen3p8\nAvailable Model Group Fallbacks=None", "type": "invalid_request_error", "param": null, "code": "400"}}

=== Case 2b developer message after the first input item (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "instructions": "You are a terse assistant.", "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello"}]}, {"type": "message", "role": "developer", "content": [{"type": "input_text", "text": "Answer in five words or fewer."}]}, {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "What is the capital of France?"}]}]}
HTTP 200
output types: ['reasoning', 'message']
output_text: Paris.

=== Case 3a namespace-grouped tool (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "namespace", "name": "mcp__weather", "description": "Weather tools from an MCP server", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}]}
HTTP 200
output types: ['reasoning', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

=== Case 3b same tool flat (kimi-k3) ===
request: {"model": "fireworks-kimi-k3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}
HTTP 200
output types: ['reasoning', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

=== Case 3c namespace-grouped tool (glm-5p3) ===
request: {"model": "fireworks-glm-5p3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "namespace", "name": "mcp__weather", "description": "Weather tools from an MCP server", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}]}
HTTP 200
output types: ['reasoning', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

=== Case 3d same tool flat (glm-5p3) ===
request: {"model": "fireworks-glm-5p3", "input": "What is the weather in Paris right now? Use the tool.", "tools": [{"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]}
HTTP 200
output types: ['reasoning', 'function_call']
function_call: get_weather {"city": "Paris"}
output_text: 

Verdicts, same three model entries on both legs (fireworks-kimi-k3, fireworks-qwen3p8 for qwen3p8-2p4t-a95b, fireworks-glm-5p3):

  • Case 1 (tool result after an empty assistant message): 200 on both legs, so the bridge at the base commit already handles it and the native path keeps it working
  • Case 2 (developer item after the first input item, qwen3.8): 400 on both legs with Fireworks' jinja template rendering failed. System message must be at the beginning. The bridge maps developer to system in place; the native path (a534b9f) does the same because Fireworks' Responses endpoint has no developer role on this model, and calling Fireworks directly with system in the later position returns the same 400. Tracked in LIT-7019
  • Case 2b (same shape on kimi-k3): 200 on both legs. Before a534b9f the native path returned Fireworks' 400 Unknown message role 'developer' here, which is what the developer-to-system mapping fixes
  • Cases 3a to 3d (type: "namespace" grouped tool vs the same tool flat, kimi-k3 and glm-5.3): 200 with function_call: get_weather {"city": "Paris"} on both legs, so namespace flattening is already in place at the base commit and the native path forwards the flattened tools

Direct probe of Fireworks' endpoint without LiteLLM, developer and system in first and later positions per model, is in fireworks_direct_developer_probe.out of the QA folder: qwen3.8 rejects developer anywhere and system later, kimi-k3 rejects developer anywhere and accepts system later, glm-5.3 accepts every combination

Case F: file_search tool over a vector store, three legs

Same proxy recipe with one Fireworks model entry plus a vector_store_registry entry (aurora-kb, an OpenAI vector store holding one support article, custom_llm_provider: openai): the bridge leg on port 24353, the tip leg on port 51035, the a534b9f leg from the earlier run on port 20225. Command per leg: zsh case_f.sh <port>, one curl to POST /v1/responses with a file_search tool naming that store, then a short Python summary of the response body

Chat bridge (3868364)

=== Case F file_search tool over an OpenAI vector store (kimi-k3) ===
request: {"model":"fireworks-kimi-k3","input":"Which coolant is approved for the Aurora Deflector Mark IV? Look it up in the knowledge base.","tools":[{"type":"file_search","vector_store_ids":["vs_6a95ab9dc7c88191b89553ce30439c64"]}],"max_output_tokens":200}
HTTP 200
output types: ['file_search_call', 'message']
file_search_call: {"status": "completed", "queries": ["Aurora Deflector Mark IV approved coolant", "Aurora Deflector Mark IV coolant approval specification"]}
answer: According to knowledge base article **KB-7311**, the only approved coolant for the **Aurora Deflector Mark IV** is **Cryoline-9**.

For reference, the same article also notes:
- Nominal frequency: 42.75 GHz
- Maintenance interval: every 1,800 flight hours
annotations: ['file_citation']
usage: 457 input tokens, 110 output tokens

Native path before 0157808 (a534b9f)

=== Case F file_search tool over an OpenAI vector store (kimi-k3) ===
request: {"model":"fireworks-kimi-k3","input":"Which coolant is approved for the Aurora Deflector Mark IV? Look it up in the knowledge base.","tools":[{"type":"file_search","vector_store_ids":["vs_6a95ab9dc7c88191b89553ce30439c64"]}],"max_output_tokens":200}
HTTP 200
output types: ['message']
answer: The user is asking me to look up information about an "Aurora Deflector Mark IV" and its approved coolant "in the knowledge base."  Here's the thing: I don't have access to any external knowledge base. I'm Claude, and I have my training data, but there's no tool or knowledge base I can query in this
annotations: []
usage: 108 input tokens, 200 output tokens

Native path at 18aa52d

=== Case F file_search tool over an OpenAI vector store (kimi-k3) ===
request: {"model":"fireworks-kimi-k3","input":"Which coolant is approved for the Aurora Deflector Mark IV? Look it up in the knowledge base.","tools":[{"type":"file_search","vector_store_ids":["vs_6a95ab9dc7c88191b89553ce30439c64"]}],"max_output_tokens":200}
HTTP 200
output types: ['file_search_call', 'message']
file_search_call: {"status": "completed", "queries": ["Aurora Deflector Mark IV approved coolant", "Aurora Deflector Mark IV coolant specification", "coolant Aurora Deflector"]}
answer: According to knowledge base article **KB-7311**, the only approved coolant for the **Aurora Deflector Mark IV** is **Cryoline-9**.

A few additional details from the same article that may be useful:
- **Nominal operating frequency:** 42.75 GHz
- **Maintenance interval:** Every 1,800 flight hours
- *
annotations: ['file_citation']
usage: 623 input tokens, 151 output tokens

Verdict: the bridge and the fixed native path both run LiteLLM's emulated search (a file_search_call item, the answer names the coolant from the article), while the native path before the fix forwarded the tool to Fireworks, which answered 200 with no search and a model that says it has no access

Case G: SDK-typed developer item through litellm.responses, before and after e9a40ad

Python SDK call with pydantic EasyInputMessage items instead of dicts (the shape the OpenAI SDK types produce), real Fireworks API, kimi-k3. qa/after8/pydantic_developer.py registers a CustomLogger whose log_pre_api_call captures the input LiteLLM sends upstream, then prints it with the status and text. The before leg runs the same file with litellm/llms/fireworks_ai/responses/transformation.py checked out from 525d9fb

=== before (transformation.py at 525d9fb14c) ===
input sent to Fireworks: [{"content": "Answer with exactly one word.", "role": "developer", "type": "message"}, {"content": "What is the capital of France?", "role": "user", "type": "message"}]
status: completed
output_text: Paris

=== after (18aa52d5e1) ===
input sent to Fireworks: [{"role": "system", "content": "Answer with exactly one word.", "type": "message"}, {"content": "What is the capital of France?", "role": "user", "type": "message"}]
status: completed
output_text: Paris

The same file against the merge base 3868364 (chat completions bridge, no Fireworks Responses config yet) does not reach Fireworks at all: the bridge's _is_input_item_tool_call_output calls .get on the pydantic item and the SDK call fails before any request is sent

=== before (38683643e0, chat bridge) ===
    raise APIConnectionError(
litellm.exceptions.APIConnectionError: litellm.APIConnectionError: APIConnectionError: Fireworks_aiException - 'EasyInputMessage' object has no attribute 'get'

Verdict: before the fix a pydantic developer item reached Fireworks unmapped as role: developer; after it, LiteLLM sends role: system, the same as it already did for dict items. Both legs return 200 today because Fireworks started accepting developer on these models on 2026-09-05 (see the caveat below); the wire body is what changed

Direct probe of Fireworks' endpoint without LiteLLM at 05:37Z on 2026-09-05, developer and system first and after the first input item:

kimi-k3            | developer first | status=incomplete text='The user asks "What is the capital of Fr' HTTP 200
kimi-k3            | system    first | status=incomplete text='The user asked "What is the capital of F' HTTP 200
qwen3p8-2p4t-a95b  | developer first | status=completed text='Paris' HTTP 200
qwen3p8-2p4t-a95b  | system    first | status=incomplete text='Paris' HTTP 200
kimi-k3            | developer later | status=incomplete text='Paris.<|close|>response' HTTP 200
kimi-k3            | system    later | status=completed text='Paris.' HTTP 200
qwen3p8-2p4t-a95b  | developer later | {"error": {"type": "invalid_request_error", "code": "invalid_request_error", "message": "jinja template rendering failed. System message must be at the beginning."}} HTTP 400
qwen3p8-2p4t-a95b  | system    later | {"error": {"type": "invalid_request_error", "code": "invalid_request_error", "message": "jinja template rendering failed. System message must be at the beginning."}} HTTP 400
glm-5p3            | developer later | status=completed text='Paris.' HTTP 200
glm-5p3            | system    later | status=completed text='Paris.' HTTP 200

Live PR risk

Breaking: none intended for the request and response shapes of POST /v1/responses. Every field the bridge accepted (instructions, temperature, max_output_tokens, metadata, store, user, parallel_tool_calls, truncation, text.format json_schema, reasoning.effort, stream) returns 200 on the head rig with the same output item types and usage fields as the base rig

Backward incompatible: response ids change shape from a base64 wrap of chat completion state to a wrap of Fireworks' own resp_... ids, so a previous_response_id minted before the upgrade gets Fireworks' 404 "Previous response not found" on the head rig (the same id continues fine on the base rig). Recorded as the Medium caveat

Regression risk: developer input items, which Codex sends first and mid-session, were 400 on the head rig before a534b9f on kimi-k3 (Unknown message role 'developer') and qwen3.8 (Unexpected message role) because Fireworks' Responses endpoint has no developer role on those models; the head rig now maps them to system the way the bridge does, so kimi-k3 answers in both positions and qwen3.8 answers with the item first and keeps the bridge's 400 with it later (glm-5.3 accepts either role in either position on both rigs). Chat completions for fireworks_ai/ models are untouched on the head rig (same model, same content, same usage as base). Streaming keeps the same event set (response.created through response.completed, reasoning summary deltas included) and the completed event still carries usage and cost. Cost headers (x-litellm-response-cost*, x-litellm-model-api-base) are populated on the head rig and match the base rig's shape; reasoning tokens are billed as output tokens on both. file_search tools were another inherited-from-OpenAI gap: OpenAIResponsesAPIConfig.supports_native_file_search is True, so the head rig before 0157808 forwarded the tool to Fireworks, which answered 200 without running any search (no file_search_call item, the model says it has no access), where the bridge emulated it through the vector store registry; the config now opts out of native file search and case F shows the emulated path back on the head

Dependency graph: ProviderConfigManager._get_python_responses_api_config now returns FireworksAIResponsesAPIConfig for fireworks_ai, which flips five surfaces from the chat bridge to Fireworks' endpoint: create (POST /v1/responses), get (GET /v1/responses/{id}), delete (DELETE /v1/responses/{id}), input items (GET /v1/responses/{id}/input_items), and cancel (POST /v1/responses/{id}/cancel). Base rig: get, delete, input items, and cancel all return litellm's 500 "not supported for fireworks_ai". Head rig: get returns the stored response (200), delete returns {"id": ..., "object": "response", "deleted": true} (200) after the 217b5c4 fix (Fireworks answers {"message": "Response deleted successfully"}, which the OpenAI parser rejected with a pydantic validation error at 4b950cd), input items and cancel return Fireworks' 404 because Fireworks has no /input_items route and refuses to cancel a completed response. resolve_fireworks_api_key and with_fireworks_session_affinity moved into common_utils.py and the chat config imports them from there; chat completions and streaming chat on the head rig behave the same as base

Not verified: POST /v1/responses/{id}/cancel on an in-progress background response (no background: true support on the Fireworks side to make one); the proxy's managed websocket path (supports_native_websocket returns False, so it takes the same route as base); Fireworks models other than kimi-k3

Re-run at 18aa52d (the branch merged with litellm_internal_staging at 3868364; the PR's own diff is byte-identical to the d98cc29 pass, seven files). The base branch moved under the PR in three places that touch this config: OpenAIResponsesAPIConfig now drops reasoning.effort for non-reasoning OpenAI models, gated on custom_llm_provider == openai, and FireworksAIResponsesAPIConfig sets fireworks_ai, so reasoning: {"effort": "low"} on kimi-k3 still passes through (200, reasoning and message items on both rigs); the get and delete parsers narrowed except Exception to except ValidationError, and get returns the stored response (200) while delete returns {"id", "object": "response", "deleted": true} (200) on the head rig where the base rig answers 500 "not supported"; _resolve_responses_api_provider_config in responses/main.py gained a supported_endpoints opt-in for OpenAI-compatible deployments that only runs when the Python config lookup returns None, and _get_python_responses_api_config still returns FireworksAIResponsesAPIConfig for fireworks_ai ahead of the JSON fallback. Same two-worker rigs, same order on both sides: chat completions on kimi-k3 unchanged (pong, same usage shape), streaming reaches response.completed with usage and cost on both, previous_response_id chaining answers from the earlier turn on the head rig (Teal) where the no-database base rig loses it (Blue.), input items and cancel keep Fireworks' 404. tests/test_litellm/llms/fireworks_ai/, tests/test_litellm/responses/, and tests/test_litellm/llms/openai/responses/ pass at the tip (1055 tests), and tests/llm_translation/test_fireworks_ai_translation.py (13 tests, real Fireworks API) passes too; the installed package set is identical on both sides

Type

🆕 New Feature

Caveats (if any)

Medium

  • previous_response_id values minted by the old bridge stop resolving after upgrade (Fireworks answers 404 "Previous response not found"; the same id keeps working on the base rig); chains restart with a fresh call. Left as is on purpose: the only fix is keeping the chat bridge alive as a second path for ids minted before the upgrade, which re-adds the code this PR retires for a window that ends at each caller's first new call

Low

  • GET /v1/responses/{id}/input_items now returns Fireworks' 404 ({"detail": "Not Found"}, no such route upstream) where the base returned litellm's 500 "not supported for fireworks_ai"
  • POST /v1/responses/{id}/cancel on a completed response returns Fireworks' 404 "Response not found" where the base returned litellm's 500; cancelling an in-progress response is not verified
  • Fireworks' usage.output_tokens_details comes back empty, so reasoning tokens are counted inside output_tokens and not broken out
  • Fireworks returns call_id values like get_weather_0, not OpenAI-style call_... ids
  • CI: the proxy-infra / Run tests (Python 3.10) red (test_http_parsing_utils.py::TestNumericFormFields::test_qualifiers_and_optionality_are_unwrapped, fixed on the base branch by fix(proxy): strip every TypedDict qualifier before numeric form-field detection #39780) and the integrations / Run tests red (test_datadog_llm_obs.py::test_a_redacted_span_carries_every_declared_guardrail_field, fixed by fix(datadog_llm_obs): keep guardrail_cost_by_unit on redacted spans #39848) both came from the base branch. litellm_internal_staging has been merged in twice since, as 525d9fb (9c05c15) and again as d98cc29 (78ad88f, after e9a40ad), each time resolving the lint budget JSON conflicts by taking the base values and re-ratcheting on the merged tree with make lint-budget-update, and a third time as 18aa52d (3868364), this time taking the four budget JSONs from the base verbatim so the branch carries no budget edit. ci/circleci: proxy_store_model_in_db_tests still fails test_chat_completion_bad_model_with_spend_logs on the last three staging pipelines too, so it is not from this PR
  • Fireworks started accepting developer items on kimi-k3 and qwen3.8 on 2026-09-05 (the 05:37Z re-probe in Case G; the 01:25Z probe in the customer samples section still got Unknown message role 'developer'), and it treats them exactly like system (a later developer on qwen3.8 fails with the same System message must be at the beginning). The developer-to-system mapping is kept: it is behavior-neutral where Fireworks accepts both, still protects models or deployments that do not, and matches the chat bridge
  • A developer item after the first input item still gets Fireworks' 400 on qwen3.8 (System message must be at the beginning): its chat template wants system first and Fireworks' own endpoint rejects a later system item too, so this matches the bridge today; tracked in LIT-7019
  • The security review on this PR flagged that LiteLLM's emulated file search runs whichever vector_store_id the model writes into its tool call instead of only the request's stores. That handler is shared by every provider without native file search and the chat bridge already ran Fireworks through it, so it is pre-existing here; tracked in LIT-7027
  • Docs: docs(fireworks_ai): document the native Responses API path litellm-docs#1205 (merged, 53f1e64) adds the Responses API section to the Fireworks page; docs(fireworks_ai): note that developer input items reach the Responses API as system messages litellm-docs#1210 (merged, c48fb77) adds the developer-to-system note

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
  • 18aa52d passes /live-pr-risk

Note

Medium Risk
Changes the default wire path for all fireworks_ai /v1/responses traffic (including response id shape and previous_response_id compatibility after upgrade); chat completions are only touched via shared header/key helpers.

Overview
Fireworks fireworks_ai/ models now use Fireworks’ native Responses API instead of the chat-completions bridge, so MCP tools, previous_response_id, streaming SSE, and related Responses features work against https://api.fireworks.ai/inference/v1/responses.

FireworksAIResponsesAPIConfig is registered in ProviderConfigManager and lazy imports. It normalizes bare model names via resolve_fireworks_resource_name, sets auth/FIREWORKS_API_BASE through shared resolve_fireworks_api_key, and adds x-session-affinity via with_fireworks_session_affinity (refactored into common_utils for chat and responses). Request input maps developer items to system after validation; delete responses map Fireworks’ message-only body to {id, object, deleted}; file_search stays on LiteLLM emulated search (supports_native_file_search false); websockets use the managed handler (supports_native_websocket false).

Tests cover registration, MCP passthrough, session affinity, streaming, delete, and env key names.

Reviewed by Cursor Bugbot for commit 18aa52d. Bugbot is set up for automated code reviews on this repo. Configure here.

@codspeed

codspeed Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lit_6348_fireworks_responses_api (18aa52d) with litellm_internal_staging (cd681a5)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Routes Fireworks AI Responses API operations through Fireworks’ native endpoint while preserving LiteLLM behavior for unsupported native features.

  • Registers FireworksAIResponsesAPIConfig in the provider and lazy-import registries.
  • Normalizes Fireworks model names, authentication, session affinity, developer messages, and delete responses.
  • Keeps file search and WebSocket behavior on LiteLLM-managed paths.
  • Adds buffered, streaming, replay, session-affinity, deletion, and provider-registration coverage.

Confidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule issues identified.

The latest revision correctly moves developer-message conversion after base input normalization, preserving dictionary and Pydantic replay inputs without duplicate processing. The earlier streaming concern is covered by a native SSE regression test, while the delete and typing findings were correctly withdrawn and all previous threads are resolved.

Important Files Changed

Filename Overview
litellm/llms/fireworks_ai/responses/transformation.py Adds the native Fireworks Responses configuration and request/response adaptations; the latest input-normalization change is correctly integrated.
litellm/llms/fireworks_ai/common_utils.py Extracts shared API-key and session-affinity helpers without changing the existing chat path’s effective behavior.
litellm/utils.py Registers Fireworks AI for native Responses configuration selection.
litellm/_lazy_imports_registry.py Adds the Fireworks Responses configuration to the lazy-import registry.
tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py Provides comprehensive mocked coverage for native requests, streaming, replay inputs, file search, authentication, sessions, and deletion.
tests/test_litellm/responses/test_responses_websocket_all_providers.py Verifies Fireworks continues to use LiteLLM’s managed WebSocket handling.

Reviews (10): Last reviewed commit: "chore: merge litellm_internal_staging in..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…itellm_lit_6348_fireworks_responses_api

# Conflicts:
#	basedpyright-code-budget.json
#	type-discipline-budget.json
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: File search treated as native
    • Overrode supports_native_file_search to return False on FireworksAIResponsesAPIConfig so file_search tools flow through the emulated chat-bridge instead of the unsupported Fireworks /responses path.

Create PR

Or push these changes by commenting:

@cursor push 61949f7db8
Preview (61949f7db8)
diff --git a/litellm/llms/fireworks_ai/responses/transformation.py b/litellm/llms/fireworks_ai/responses/transformation.py
--- a/litellm/llms/fireworks_ai/responses/transformation.py
+++ b/litellm/llms/fireworks_ai/responses/transformation.py
@@ -94,3 +94,6 @@
 
     def supports_native_websocket(self) -> bool:
         return False
+
+    def supports_native_file_search(self) -> bool:
+        return False

diff --git a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
--- a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
@@ -105,6 +105,11 @@
     assert config.custom_llm_provider == LlmProviders.FIREWORKS_AI
 
 
+def test_fireworks_ai_does_not_advertise_native_file_search() -> None:
+    """Fireworks has no vector-store file_search, so the emulated chat-bridge path must handle it."""
+    assert FireworksAIResponsesAPIConfig().supports_native_file_search() is False
+
+
 def test_responses_call_hits_native_endpoint_with_mcp_tool_untouched() -> None:
     client: Final = _mock_http_client(_fireworks_response("accounts/fireworks/models/kimi-k3"))
     mcp_tool: Final[Mcp] = {

You can send follow-ups to the cloud agent here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri closed this Sep 5, 2026
auto-merge was automatically disabled September 5, 2026 03:08

Pull request was closed

@mateo-berri mateo-berri reopened this Sep 5, 2026
@mateo-berri mateo-berri closed this Sep 5, 2026
auto-merge was automatically disabled September 5, 2026 03:23

Pull request was closed

@mateo-berri mateo-berri reopened this Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Developer mapping crashes on pydantic items
    • Guarded _developer_item_as_system with isinstance(item, dict) so pydantic output items pass through untouched and reach the OpenAI base class's _validate_input_param for dict conversion.
  • ✅ Fixed: Session affinity drops session_id
    • Extended _session_params to also forward the top-level session_id extra so get_fireworks_session_id can pin the request via x-session-affinity.

Create PR

Or push these changes by commenting:

@cursor push f9145b6a5a
Preview (f9145b6a5a)
diff --git a/litellm/llms/fireworks_ai/responses/transformation.py b/litellm/llms/fireworks_ai/responses/transformation.py
--- a/litellm/llms/fireworks_ai/responses/transformation.py
+++ b/litellm/llms/fireworks_ai/responses/transformation.py
@@ -27,12 +27,16 @@
 def _session_params(litellm_params: GenericLiteLLMParams) -> Mapping[str, object]:
     extras: Final[Mapping[str, object]] = litellm_params.model_extra or MappingProxyType({})
     return MappingProxyType(
-        {"litellm_session_id": extras.get("litellm_session_id"), "metadata": extras.get("litellm_metadata")}
+        {
+            "litellm_session_id": extras.get("litellm_session_id"),
+            "session_id": extras.get("session_id"),
+            "metadata": extras.get("litellm_metadata"),
+        }
     )
 
 
 def _developer_item_as_system(item: ResponseInputItemParam) -> ResponseInputItemParam:
-    if "role" not in item or item["role"] != "developer":
+    if not isinstance(item, dict) or item.get("role") != "developer":
         return item
     return EasyInputMessageParam(role="system", content=item["content"], type="message")
 

diff --git a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
--- a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
@@ -197,6 +197,43 @@
     assert headers["x-session-affinity"] == "sess-42"
 
 
+def test_responses_call_sends_session_affinity_for_top_level_session_id() -> None:
+    client: Final = _mock_http_client(_fireworks_response("accounts/fireworks/models/kimi-k3"))
+    with patch(HTTPX_CLIENT_FACTORY, return_value=client):
+        litellm.responses(model="fireworks_ai/kimi-k3", input="hi", api_key="fw-test-key", session_id="sess-top")
+    _, headers, _ = _sent_request(client)
+    assert headers["x-session-affinity"] == "sess-top"
+
+
+def test_responses_call_accepts_pydantic_output_items_replayed_as_input() -> None:
+    client: Final = _mock_http_client(_fireworks_response("accounts/fireworks/models/kimi-k3"))
+    replay: Final = [  # mutable-ok: the Responses API takes input items as a JSON list
+        ResponseOutputMessage(
+            id="msg_prev",
+            status="completed",
+            role="assistant",
+            type="message",
+            content=(ResponseOutputText(type="output_text", text="hi back", annotations=()),),
+        ),
+        ResponseFunctionToolCall(
+            id="fc_prev",
+            call_id="call_prev",
+            name="get_weather",
+            arguments='{"city": "Paris"}',
+            status="completed",
+            type="function_call",
+        ),
+        {"role": "developer", "content": "Answer with exactly one word."},
+    ]
+    with patch(HTTPX_CLIENT_FACTORY, return_value=client):
+        litellm.responses(model="fireworks_ai/kimi-k3", input=replay, api_key="fw-test-key")
+    _, _, body = _sent_request(client)
+    sent: Final = tuple(body["input"])
+    assert sent[0]["type"] == "message" and sent[0]["role"] == "assistant"
+    assert sent[1]["type"] == "function_call" and sent[1]["call_id"] == "call_prev"
+    assert sent[2] == {"role": "system", "content": "Answer with exactly one word.", "type": "message"}
+
+
 def test_responses_call_keeps_caller_supplied_session_affinity_header() -> None:
     client: Final = _mock_http_client(_fireworks_response("accounts/fireworks/models/kimi-k3"))
     pinned: Final[Mapping[str, str]] = MappingProxyType({"x-session-affinity": "explicit-node"})

You can send follow-ups to the cloud agent here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@tin-berri tin-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 18aa52d. Configure here.

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 7, 2026
@mateo-berri
mateo-berri merged commit bb8fe4a into litellm_internal_staging Sep 7, 2026
116 of 123 checks passed
@mateo-berri
mateo-berri deleted the litellm_lit_6348_fireworks_responses_api branch September 7, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants