Skip to content

chore: allow passing scope id for watsonx inferencing - #18959

Merged
2 commits merged into
BerriAI:litellm_staging_01_13_2026from
MateuszOssGit:added-support-for-space_id
Jan 13, 2026
Merged

chore: allow passing scope id for watsonx inferencing#18959
2 commits merged into
BerriAI:litellm_staging_01_13_2026from
MateuszOssGit:added-support-for-space_id

Conversation

@MateuszOssGit

Copy link
Copy Markdown
Contributor

Relevant issues

Allow passing scope id for watsonx inferencing

Pre-Submission checklist

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

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • poetry run pytest tests/test_litellm/llms/watsonx/test_watsonx.py -x -vv
    Screenshot 2026-01-12 at 12 47 51
  • poetry run pytest tests/llm_translation/test_watsonx.py -x -vv
    Screenshot 2026-01-12 at 12 55 15

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix
🧹 Refactoring
✅ Test

Changes

The changes introduced allow for the successful completion of the following scenarios:

ENV: Python LieteLLM package 1.80.15

  1. The watsonx.ai API docs (https://cloud.ibm.com/apidocs/watsonx-ai#text-chat) allow to run inference in both space and project scopes. But with current impelmentation in LiteLLM, there is impossible to run inference in space scope:
from litellm import completion

## Call WATSONX `/text/chat` endpoint - supports function calling
response = completion(
  model="watsonx/meta-llama/llama-3-1-8b-instruct",
  messages=[{ "content": "what is your favorite colour?","role": "user"}],
  space_id="space_id"
)

Error:


AuthenticationError: litellm.AuthenticationError: watsonxException - Error: Watsonx project_id not set. Set WX_PROJECT_ID in environment variables or pass in as a parameter.
  1. The deployments does not require scope id in payload. Also, the deployment can be created in project scope - current implementation only consider deployments in space.
from litellm import completion

response = completion(
    model="watsonx_text/deployment/6d6783d5-d8bb-4088-b152-6c9fa7fb2f0a",
    messages=[{"role": "user", "content": "What is the capital of France?"}],
    project_id="project_id",
)

Error:

...
APIConnectionError: litellm.APIConnectionError: Watsonx_textException - Error: space_id is required for models called using the 'deployment/' endpoint. Pass in the space_id as a parameter or set it in the WX_SPACE_ID environment variable.

second scenario:

from litellm import completion

response = completion(
    model="watsonx_text/deployment/ef1401f2-1358-4052-b729-4050e50bfc16",
    messages=[{"role": "user", "content": "What is the capital of France?"}],
    space_id="space_id",
    project_id="project_id"
)

Error:

APIConnectionError: litellm.APIConnectionError: Watsonx_textException - {"errors":[{"code":"json_validation_error","message":"Json document validation error: 'project_id' or 'space_id' cannot be specified in the request body","more_info":"https://cloud.ibm.com/apidocs/watsonx-ai#deployments-text-generation"}],"trace":"4e0bb86eadae2093ac9d4bc6cb5e5c81","status_code":400}

@vercel

vercel Bot commented Jan 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Jan 12, 2026 0:29am

@MateuszOssGit MateuszOssGit changed the title chore: allow passing scope id for watsonx inferencing chore: allow passing scope_id for watsonx inferencing Jan 12, 2026
@MateuszOssGit MateuszOssGit changed the title chore: allow passing scope_id for watsonx inferencing chore: allow passing scope id for watsonx inferencing Jan 12, 2026
@MateuszOssGit

MateuszOssGit commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

Failing tests are not related my changes

@Sameerlite @Chesars @Harshit28j @ishaan-berri @krrishdholakia Could you please review my PR and merge if possible?
These changes are quite important for our AI Agents templates in https://github.com/IBM/watsonx-developer-hub/tree/main/agents/base

@MateuszOssGit

Copy link
Copy Markdown
Contributor Author

@ishaan-jaff Could you please review my PR and merge if possible?

@ghost
ghost changed the base branch from main to litellm_staging_01_13_2026 January 13, 2026 22:17
@ghost
ghost merged commit 72dc65f into BerriAI:litellm_staging_01_13_2026 Jan 13, 2026
6 of 7 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
* chore: allow inference with space

* make lint and make format
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant