The problem we were having is non-admin users trying to use
`/engines/{model}/chat/completions` were getting an HTTP 401 error.
```shell
$ curl -sSL 'http://localhost:4000/engines/gpt-35-turbo-0125/chat/completions' \
--header "Authorization: Bearer ${LITELLM_KEY}" \
--header 'Content-Type: application/json' \
--data ' {
"model": "gpt-35-turbo-0125",
"messages": [
{
"role": "user",
"content": "Write a poem about LiteLLM"
}
]
}' \
| jq '.'
{
"error": {
"message": "Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/engines/gpt-35-turbo-0125/chat/completions. Your role=unknown. Your user_id=someone@company.com",
"type": "auth_error",
"param": "None",
"code": 401
}
}
```
This seems to be related to code in `user_api_key_auth` that checks that the URL
matches a list of routes that are allowed for non-admin users, where the list of
routes is in `LiteLLMRoutes.openai_routes.value`. The problem is that the route
`/engines/{model}/chat/completions` is not in that list and furthermore, that
wouldn't even work if it were, because the comparison is done with
`request.url.path` and that will have the actual model name in it (e.g.:
`gpt-35-turbo-0125`), rather than `{model}`.
I added a new list `LiteLLMRoutes.openai_route_names` and added the route
**names** to that list. Then I added a check in `user_api_key_auth` to see if
the route name is in the list of route names.
```
ImportError while loading conftest '/astra-assistants-api/tests/openai-sdk/conftest.py'.
conftest.py:13: in <module>
from impl.astra_vector import CassandraClient
../../impl/astra_vector.py:45: in <module>
from impl.services.inference_utils import get_embeddings
../../impl/services/inference_utils.py:5: in <module>
import litellm
.cache/pypoetry/virtualenvs/astra-assistants-api-eiSmbCzm-py3.10/lib/python3.10/site-packages/litellm/__init__.py:678: in <module>
from .main import * # type: ignore
.cache/pypoetry/virtualenvs/astra-assistants-api-eiSmbCzm-py3.10/lib/python3.10/site-packages/litellm/main.py:73: in <module>
from .llms.azure_text import AzureTextCompletion
.cache/pypoetry/virtualenvs/astra-assistants-api-eiSmbCzm-py3.10/lib/python3.10/site-packages/litellm/llms/azure_text.py:23: in <module>
openai_text_completion_config = OpenAITextCompletionConfig()
.cache/pypoetry/virtualenvs/astra-assistants-api-eiSmbCzm-py3.10/lib/python3.10/site-packages/litellm/llms/openai.py:192: in __init__
for key, value in locals_.items():
E RuntimeError: dictionary changed size during iteration
```