Skip to content

Jupyternaut sidebar 404s when Azure deployment name matches model name (gpt-4o) #1492

@rickmcgeer

Description

@rickmcgeer

Description

When using the Jupyternaut sidebar with an Azure OpenAI deployment whose deployment name is identical to the base model name (e.g., gpt-4o), the sidebar fails with a 404 Resource not found.
However, the same configuration works correctly with the JupyterAI magic commands (%%ai azure-chat-openai:gpt-4o).

This indicates that the sidebar’s request builder forms the REST URL differently from the kernel-side client.

Reproduce

  1. In Azure AI Studio, create a deployment:
  • Model: gpt-4o
  • Deployment name: gpt-4o
  1. Configure JupyterAI:
{
  "model_provider_id": "azure-chat-openai:gpt-4o",
  "fields": {
    "azure-chat-openai:gpt-4o": {
      "azure_endpoint": "https://<resource>.openai.azure.com/",
      "api_version": "2024-02-15-preview"
    }
  },
  "api_keys": {
    "AZURE_OPENAI_API_KEY": "<key>"
  }
}
  1. Run in a Notebook:
%%ai azure-chat-openai:gpt-4o
drive time from la to sf
  1. In the Jupyternaut sidebar, run the same query
    ❌ Fails: 404 Resource not found.

  2. Go to '...'

  3. Click on '...'

  4. Scroll down to '...'

  5. See error '...'

Expected behavior

Both the sidebar and the magics should form identical Azure REST calls:

POST https://<resource>.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=...

Actual Behavior

  • The kernel (magic) path is correct and succeeds.
  • The sidebar appears to mis-form the URL or confuse model_id vs deployment_id when the names are identical, resulting in a 404.

Workaround

When a deployment name different from the model is chosen, the sidebar succeeds

{
    "model_provider_id": "azure-chat-openai:gpt-4o-jupyternaut",
    "embeddings_provider_id": null,
    "send_with_shift_enter": false,
    "fields": {
        "azure-chat-openai:gpt-4o": {
            "azure_endpoint": "https://oai-rt-mage-dev.openai.azure.com/openai/v1/",
            "api_version": "2024-11-20",
            "azure_deployment": "gpt-4o-jupyternaut"
        }
    },
    "api_keys": {
        "AZURE_OPENAI_API_KEY":  <key>
    },
    "completions_model_provider_id": null,
    "completions_fields": {},
    "embeddings_fields": {}
}

Context

here is the full error message. Unfortunately, some of the critical detail was redacted before it hit the logs...

Traceback (most recent call last):
  File "/opt/conda/lib/python3.13/site-packages/jupyter_ai/chat_handlers/base.py", line 226, in on_message
    await self.process_message(message)
  File "/opt/conda/lib/python3.13/site-packages/jupyter_ai/chat_handlers/default.py", line 71, in process_message
    await self.stream_reply(inputs, message)
  File "/opt/conda/lib/python3.13/site-packages/jupyter_ai/chat_handlers/base.py", line 564, in stream_reply
    async for chunk in chunk_generator:
    ...<32 lines>...
            break
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5901, in astream
    async for item in self.bound.astream(
    ...<4 lines>...
        yield item
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5901, in astream
    async for item in self.bound.astream(
    ...<4 lines>...
        yield item
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3677, in astream
    async for chunk in self.atransform(input_aiter(), config, **kwargs):
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3659, in atransform
    async for chunk in self._atransform_stream_with_config(
    ...<5 lines>...
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2478, in _atransform_stream_with_config
    chunk = await coro_with_context(py_anext(iterator), context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3626, in _atransform
    async for output in final_pipeline:
        yield output
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5940, in atransform
    async for item in self.bound.atransform(
    ...<4 lines>...
        yield item
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5257, in atransform
    async for output in self._atransform_stream_with_config(
    ...<5 lines>...
        yield output
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2478, in _atransform_stream_with_config
    chunk = await coro_with_context(py_anext(iterator), context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5237, in _atransform
    async for chunk in output.astream(
    ...<7 lines>...
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 5901, in astream
    async for item in self.bound.astream(
    ...<4 lines>...
        yield item
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3677, in astream
    async for chunk in self.atransform(input_aiter(), config, **kwargs):
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3659, in atransform
    async for chunk in self._atransform_stream_with_config(
    ...<5 lines>...
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2478, in _atransform_stream_with_config
    chunk = await coro_with_context(py_anext(iterator), context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3626, in _atransform
    async for output in final_pipeline:
        yield output
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/output_parsers/transform.py", line 95, in atransform
    async for chunk in self._atransform_stream_with_config(
    ...<2 lines>...
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 2438, in _atransform_stream_with_config
    final_input: Optional[Input] = await py_anext(input_for_tracing, None)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/utils/aiter.py", line 78, in anext_impl
    return await __anext__(iterator)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/utils/aiter.py", line 133, in tee_peer
    item = await iterator.__anext__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 1634, in atransform
    async for output in self.astream(final, config, **kwargs):
        yield output
  File "/opt/conda/lib/python3.13/site-packages/langchain_core/language_models/chat_models.py", line 615, in astream
    async for chunk in self._astream(
    ...<11 lines>...
        yield chunk.message
  File "/opt/conda/lib/python3.13/site-packages/langchain_openai/chat_models/azure.py", line 823, in _astream
    async for chunk in super()._astream(*args, **kwargs):
        yield chunk
  File "/opt/conda/lib/python3.13/site-packages/langchain_openai/chat_models/base.py", line 1362, in _astream
    response = await self.async_client.create(**payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 2603, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
    ...<48 lines>...
    )
    ^
  File "/opt/conda/lib/python3.13/site-packages/openai/_base_client.py", line 1794, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.13/site-packages/openai/_base_client.py", line 1594, in request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}
  • Operating System and version: Google Kubernetes Engine
  • Browser and version: Version 141.0.7390.77 (Official Build) (64-bit)
  • JupyterLab version: Version 4.4.7
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here, if applicable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBugs reported by users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions