aura-mocks-openai-api plugin

Description of the aura-mocks-openai-api plugin that mocks some of the services defined in the Azure OpenAI Service, used mainly by the Aura Gateway API service.

Description

The aura-mocks-openai-api plugin contains the services used by aura-gateway-api to work without real OpenAI services.

Find more information in the Github repository:
https://github.com/Telefonica/aura-mocks-server/tree/master/src/plugins/aura-mocks-openai-api

Currently, the plugin mocks the following services:

This is part of aura-mocks-server project.

aura-mocks-openai-api API

Endpoints description

Currently, the mock for OpenAI has the following endpoints implemented:

Enpoint Method Group description
/openai/deployments/:deployment_id/chat/completions POST Chat Create chat completions

Create chat completions

The endpoint /openai/deployments/:deployment_id/chat/completions is used to create a new chat completion. It is a POST request that receives the following query parameters:

Parameter Type Description
api-version string version of the API to be used

The response can be modified using the content field of the request body.

Using a specific response

The content field of the request body can be used to return a specific response:

{
    "messages": [
        {
            "role": "user",
            "content": "error_400_content_filter"
        }
    ]
}

Using retries profile

The content field of the request body can be used to return responses based on a profile. The retries profile allows to return different responses for each retry. Example:

{
    "messages": [
        {
            "role": "user",
            "content": "user2|retries:status-500&status-200"
        }
    ]
}

In the example above, the retries profile will return the first response with status 500 and then the second response with status 200.

Defined responses

The following table shows the different mock responses that can be used:

Mock response Description
error_400_content_filter Returns a 400 error with content filter error
error_401_incorrect_api_key Returns a 401 error with incorrect APIKey
error_429_exceeded_quota Returns a 429 error with exceeded quota
error_429_rate_limit_reached Returns a 429 error with rate limit reached
error_500_server_error Returns a 500 error with server error
error_503_engine_overloaded Returns a 503 error with engine overloaded
missing_response Returns a 200 response with an empty response body
success_length Returns a 200 success response
success_stop Returns a 200 success response with finish_reason stop

The “error_429_exceeded_quota” and “error_429_rate_limit_reached” responses will have the “Retry-After” header set to 5 seconds.