Skip to content

Desktop sessions fail with API Error: Connection error when using LiteLLM Anthropic gateway #570

@lost9999

Description

@lost9999

Summary

PromptX Desktop session requests fail with:

  • API Error: Connection error.

This occurs when using LiteLLM as an Anthropic-format gateway for AgentX / Claude Agent SDK.

Environment

  • OS: Windows
  • PromptX Desktop: 2.4.0
  • PromptX MCP Server: 2.2.1
  • Claude Agent SDK: 0.1.77
  • LiteLLM Proxy: 1.83.3-nightly
  • Node: 22.20.0

Symptom in Desktop

After sending a message in PromptX Desktop, the UI shows:

Error (success)
API Error: Connection error.

Repro

  1. Configure PromptX Desktop / AgentX to use LiteLLM via Anthropic-style gateway
  2. Open a new session
  3. Send a message such as:
    • 激活女娲,我要创建一个角色
  4. Observe:
    • API Error: Connection error.

Gateway behavior observed locally

The gateway responds on:

  • /v1/messages
  • /v1/messages?beta=true

However Claude Agent SDK debug logs show streaming/parser failures such as:

Error streaming, falling back to non-streaming mode: Unexpected event order, got message_start before receiving "message_stop"

and earlier also:

Error streaming, falling back to non-streaming mode: Connection error.

Expected

PromptX Desktop sessions should stream and complete normally through a LiteLLM Anthropic gateway.

Actual

Desktop sessions fail with API Error: Connection error. and Claude Agent SDK appears unable to complete the request flow.

Additional notes

Anthropic's Claude Code gateway docs require gateways to correctly support at least:

  • /v1/messages
  • /v1/messages/count_tokens
  • Anthropic header forwarding
  • correct Anthropic SSE/event ordering

This may be a PromptX/AgentX compatibility issue with LiteLLM's Anthropic gateway path rather than a plain local proxy configuration issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions