marimo
marimo copied to clipboard
DeepSeek API incompatible with AI chat - content format error after first message
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:**
- Configure marimo with DeepSeek API credentials
- Open AI chat panel in editor
- Send first message - works fine
- 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://github.com/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.
I'd like to contribute