# Jupyter AI + Internal server

**URL:** <https://discourse.jupyter.org/t/jupyter-ai-internal-server/26671>\
**Category:** JupyterLab\
**Created:** [July 1, 2024, 5:42pm UTC](https://discourse.jupyter.org/t/jupyter-ai-internal-server/26671 "2024-07-01T17:42:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielCastro](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@DanielCastro](https://discourse.jupyter.org/u/DanielCastro)\
**Post date:** [July 1, 2024, 5:42pm UTC](https://discourse.jupyter.org/t/jupyter-ai-internal-server/26671/1 "2024-07-01T17:42:46Z")

</div>

Hi all,

We have the following environment:

```auto
bash-5.1$ /opt/python/3.9.14/bin/jupyter --version
Selected Jupyter core packages...
IPython : 8.18.1
ipykernel : 6.29.3
ipywidgets : 8.1.2
jupyter_client : 7.4.9
jupyter_core : 5.7.1
jupyter_server : 2.14.1
jupyterlab : 4.1.4
nbclient : 0.9.0
nbconvert : 7.16.1
nbformat : 5.9.2
notebook : 6.5.6
qtconsole : 5.5.1
traitlets : 5.14.1

```

OS: RHEL 9.3

We have a Posit Platform with Jupyter notebook installed. We want to use Jupyter AI with our internal LLM server (model : chatgpt 3.5). I tested the connection with postman and it is working. The steps are the following:

**Step 1 - Get the token - Authorization**

> https: //login .microsoftonline.com/\< tenant id \>/oauth2/v2.0/authorize?response\_type=code&client\_id=\< client id \>&scope=\< api scope \>&redirect\_uri=\<redirect\_uri\>

This returns:

> https://redirect\_uri?code=\< code \>&session\_state=\< session\_state \>

Then postman send a post:

> [https://login.microsoftonline.com/](https://login.microsoftonline.com/)/oauth2/v2.0/token  
> Request Body:  
> grant\_type: “authorization\_code”  
> code: “\< code generated in the previous step \>”  
> redirect\_uri: “\<redirect\_uri\>”  
> client\_id: “\<client\_id\>”  
> client\_secret: “\< client secret \>”

**Step 2 - Get App Context id**

> POST [https://login.microsoftonline.com/](https://login.microsoftonline.com/)/oauth2/v2.0/token  
> Request Body  
> client\_id: “\< client id \>”  
> scope: “\< api scope \>”  
> client\_secret: “\< client secret \>”  
> grant\_type: “client\_credentials”  
> Response Body  
> {“token\_type”:“Bearer”,“expires\_in”:3599,“ext\_expires\_in”:3599,“access\_token”:" \< token \>"}

**Step 3 - Send the message:**

> POST https://\< LLM Server \>/api/tryout/v1/public/gpt3/chats/messages  
> Request Body:  
> {“messages”:[{“role”:“user”,“content”:“good morning”}],“model”:“gpt3”,“temperature”:0.1}  
> Response Body:  
> [{“role”:“assistant”,“content”:“Good morning! How are you today?”,“tokenCount”:17,“tokenLimitExceeded”:false}]

**How do I configure Jupyter-Ai to work with that?**

> File “/home/\< user \>/.local/lib/python3.9/site-packages/openai/\_base\_client.py”, line 1599, in \_request  
> raise self.\_make\_status\_error\_from\_response(err.response) from None  
> openai.APIStatusError: Error code: 405

My Configuration in Jupyter AI:  
Language Model: OpenAI::gpt-3.5-turbo  
Base API URL: https://\< my server \>/api/tryout/v1/public/gpt3/chats/messages  
API Key: \< My Server API key \>

Thanks in advance !
