"Internal server error" with custom provider to my university's API #9482

Open
opened 2026-02-16 18:12:32 -05:00 by yindo · 2 comments
Owner

Originally created by @myerspat on GitHub (Feb 16, 2026).

Originally assigned to: @rekram1-node on GitHub.

Question

Hello!

I'm trying to use my API access through my university with opencode but no matter what configuration I use I always either get a "Resource Not Found" error or an "Internal Server Error". Here is my config:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "um-gpt": {
      "name": "U-M GPT",
      "npm": "@ai-sdk/azure",
      "options": {
        "baseURL": "https://api.umgpt.umich.edu/azure-openai-api/openai",
        "apiVersion": "2025-04-01-preview",
        "apiKey": "{env:API_KEY}",
        "useDeploymentBasedUrls": true,
        "headers": {
          "api-key": "{env:API_KEY}",
          "openai-organization": "{env:SHORTCODE}",
        },
      },
      "models": {
        "gpt-4o": {
          "id": "gpt-4o",
          "limit": {
            "context": 128000,
            "output": 16384
          }
        },
      },
    }
  }
}

This Python code works so I know that I can connect and talk to the models:

from openai import AzureOpenAI
import os

# Sets the current working directory to be the same as the file.
os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Create Azure client
client = AzureOpenAI(
    api_key=os.environ["API_KEY"],
    api_version="2025-04-01-preview",
    azure_endpoint="https://api.umgpt.umich.edu/azure-openai-api",
    organization=os.environ["SHORTCODE"],
)

# Create Query
messages = [
    {
        "role": "system",
        "content": "You are a helpful assistant.  Always say GO BLUE! at the end of your response.  Respond in json format.",
    },
    {
        "role": "user",
        "content": "Explain step by step. Where is the University of Michigan?",
    },
]

# Send a completion request.
response = client.chat.completions.create(
    model="gpt-4o",
    messages=messages,
    temperature=0,
    stop=None,
    response_format={"type": "json_object"},
)

# Print response.
print(response.choices[0].message.content)

They do not allow direct access to the Azure subscription but I was hoping since the Python code works opencode would work too. I'm running opencode in terminal in WSL2. Here is the error from the logs:

ERROR 2026-02-16T17:33:51 +0ms service=session.processor error=Internal Server Error stack="AI_APICallError: Internal Server Error\n    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:950:18)\n    at processTicksAndRejections (native:7:39)" process

Thanks for any help in diagnosing this and I'd be happy to provide any needed details.

Originally created by @myerspat on GitHub (Feb 16, 2026). Originally assigned to: @rekram1-node on GitHub. ### Question Hello! I'm trying to use my API access through my university with opencode but no matter what configuration I use I always either get a "Resource Not Found" error or an "Internal Server Error". Here is my config: ``` { "$schema": "https://opencode.ai/config.json", "provider": { "um-gpt": { "name": "U-M GPT", "npm": "@ai-sdk/azure", "options": { "baseURL": "https://api.umgpt.umich.edu/azure-openai-api/openai", "apiVersion": "2025-04-01-preview", "apiKey": "{env:API_KEY}", "useDeploymentBasedUrls": true, "headers": { "api-key": "{env:API_KEY}", "openai-organization": "{env:SHORTCODE}", }, }, "models": { "gpt-4o": { "id": "gpt-4o", "limit": { "context": 128000, "output": 16384 } }, }, } } } ``` This Python code works so I know that I can connect and talk to the models: ``` from openai import AzureOpenAI import os # Sets the current working directory to be the same as the file. os.chdir(os.path.dirname(os.path.abspath(__file__))) # Create Azure client client = AzureOpenAI( api_key=os.environ["API_KEY"], api_version="2025-04-01-preview", azure_endpoint="https://api.umgpt.umich.edu/azure-openai-api", organization=os.environ["SHORTCODE"], ) # Create Query messages = [ { "role": "system", "content": "You are a helpful assistant. Always say GO BLUE! at the end of your response. Respond in json format.", }, { "role": "user", "content": "Explain step by step. Where is the University of Michigan?", }, ] # Send a completion request. response = client.chat.completions.create( model="gpt-4o", messages=messages, temperature=0, stop=None, response_format={"type": "json_object"}, ) # Print response. print(response.choices[0].message.content) ``` They do not allow direct access to the Azure subscription but I was hoping since the Python code works opencode would work too. I'm running opencode in terminal in WSL2. Here is the error from the logs: ``` ERROR 2026-02-16T17:33:51 +0ms service=session.processor error=Internal Server Error stack="AI_APICallError: Internal Server Error\n at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:950:18)\n at processTicksAndRejections (native:7:39)" process ``` Thanks for any help in diagnosing this and I'd be happy to provide any needed details.
yindo added the windows label 2026-02-16 18:12:32 -05:00
Author
Owner

@rekram1-node commented on GitHub (Feb 16, 2026):

Let's see

@rekram1-node commented on GitHub (Feb 16, 2026): Let's see
Author
Owner

@rekram1-node commented on GitHub (Feb 16, 2026):

@myerspat try this::

"options": {
        "baseURL": "https://api.umgpt.umich.edu/azure-openai-api/openai",
        "apiVersion": "2025-04-01-preview",
        "apiKey": "{env:API_KEY}",
        "useCompletionUrls": true,  //// THIS IS THE CHANGE
        "headers": { 
          "api-key": "{env:API_KEY}",
          "openai-organization": "{env:SHORTCODE}",
        },
      },
@rekram1-node commented on GitHub (Feb 16, 2026): @myerspat try this:: ``` "options": { "baseURL": "https://api.umgpt.umich.edu/azure-openai-api/openai", "apiVersion": "2025-04-01-preview", "apiKey": "{env:API_KEY}", "useCompletionUrls": true, //// THIS IS THE CHANGE "headers": { "api-key": "{env:API_KEY}", "openai-organization": "{env:SHORTCODE}", }, }, ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9482