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. 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.