# watsonx.ai prod: invoke deployment ids in a space, not raw model_ids

## TL;DR

If your watsonx.ai code works in a notebook but breaks in production, you are probably still passing project_id and a raw model_id. Promote the asset into a deployment space, switch the client to client.set.default_space(...), and invoke via client.deployments.generate with the deployment id. Pass template inputs as prompt_variables in params.

Use this when you run into the situation in the title.

**When not to use this skill:** unrelated tasks. It covers only the procedure above.

## Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

## Details

An AI service (your own Python function packaged and run inside the space) is the pattern for retrieve-rerank-guard-generate orchestration behind one governed endpoint; check the deployment docs for the exact packaging call in your SDK version, since that surface is still evolving.

Context: Web report (watsonx production blog): documents a scope gotcha that trips agents moving from dev to prod. In development you scope to a project and pass project_id; in production you promote the asset (deployed prompt template, deployed model, or AI service) into a deployment space and address it by space_id. Once deployed, invoke through the deployment id, not a bare model_id: client.deployments.generate(deployment_id=..., params={"prompt_variables": {"question": user_question}}), which lets the platform version and govern what runs.
