Skip to content

DeepSeek API incompatible with AI chat - content format error after first message #7036

@evgspacdmy

Description

@evgspacdmy

When using DeepSeek API (https://api.deepseek.com) with marimo's built-in AI assistant chat panel, the first message works but subsequent messages fail with:

Error code: 400 - {'error': {'message': "Failed to deserialize the JSON body into the target type: messages[2]: invalid type: sequence, expected a string at line 1 column 14163", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

Root cause: Marimo sends message content in array format with 'parts' structure, but DeepSeek API only accepts simple string content for the message content field.

Configuration used:
[ai.open_ai]
api_key = "sk-..."
model = "deepseek-chat"
base_url = "https://api.deepseek.com"


**Steps to reproduce:**
  1. Configure marimo with DeepSeek API credentials
  2. Open AI chat panel in editor
  3. Send first message - works fine
  4. Send second message - fails with above error

**Expected behavior:**

Multi-turn conversations should work with DeepSeek API, as it claims OpenAI compatibility


<img width="1234" height="1404" alt="Image" src="https://cdn2-s1-movies.ddyy.vip/user-attachments/assets/38562ad3-e531-4e3c-a778-94bdd7e4ea09" />


**Additional context:**

Similar issue reported with other tools (Claude Code, LiteLLM) where DeepSeek's partial OpenAI compatibility causes content format errors.

Suggested fix: When base_url contains "api.deepseek.com", ensure message content is sent as string rather than array format.

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