spacedriveapp / spacedriveapp/spacebot

Add LiteLLM provider support

Open Beginner friendly
#507 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.4k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

Add native support for LiteLLM Proxy as a model provider. LiteLLM provides a unified OpenAI-compatible API gateway for 100+ LLM providers (OpenAI, Anthropic, Gemini, etc.) with features like load balancing, fallbacks, and spend tracking.

Current Behavior

When configuring LiteLLM as a custom provider, Spacebot sends model names with the provider prefix (e.g., litellm/kimi-k2p5), but LiteLLM expects plain model IDs (kimi-k2p5). This results in 400 errors:
400: {'error': '/chat/completions: Invalid model name passed in model=litellm/kimi-k2p5'}

Proposed Solution

Add LiteLLM to the remap_model_name_for_api() function in src/llm/model.rs to strip the provider prefix:

fn remap_model_name_for_api(provider: &str, model_name: &str) -> String {
    if provider == "zai-coding-plan" {
        // Coding Plan endpoint expects plain model ids (e.g. "glm-5").
        model_name
            .strip_prefix("zai/")
            .unwrap_or(model_name)
            .to_string()
    } else if provider == "litellm" {
        // LiteLLM expects plain model ids (e.g. "kimi-k2p5").
        model_name
            .strip_prefix("litellm/")
            .unwrap_or(model_name)
            .to_string()
    } else {
        model_name.to_string()
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/llm/model.rs at remap_model_name_for_api() and compare its existing provider-specific model handling with the LiteLLM behavior described in the issue. Verify that LiteLLM requests receive plain model IDs rather than the litellm/ prefix, and confirm the resulting request no longer produces the reported 400 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.