Skip to main content

TrustNest Azure OpenAI via APIM Documentation with Curl

In this document, you will find basic examples that uses curl to call Azure OpenAI through the TrustNest API Manager.

APIM JWT token and Azure APIM API key

For security and tracking purposes, requests to Azure OpenAI API must include a JWT token and a APIM subscription key. To do so, we use the custom headers TrustNest-Apim-Subscription-Key and Authorization.

Usage

Create Chat Completion

curl -L -X POST 'https://trustnest.azure-api.net/genai-aoai-inference/v1/deployments/gpt35-4k/chat/completions?api-version=2023-05-15' \
-H 'TrustNest-Apim-Subscription-Key: <your-trustnest-apim-subscription-key>' \
-H 'Authorization: Bearer <your-trustnest-apim-access-token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-35-turbo",
"messages": [{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Implement basic merge sort algorithm using python."}]
}'

Get embeddings

curl -L -X POST 'https://trustnest.azure-api.net/genai-aoai-inference/v1/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15' \
-H 'TrustNest-Apim-Subscription-Key: <your-trustnest-apim-subscription-key>' \
-H 'Authorization: Bearer <your-trustnest-apim-access-token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"model": "text-embedding-ada-002",
"input": "This is a test."
}'