Quickstart

This quickstart provides a rapid introduction to integrating an application with a Blueteam AI Endpoint. enforcement point reverse proxy.

Integrating with a Blueteam endpoint

First, create an endpoint:

  1. Create an Endpoint. Note it's "endpoint URL."
  2. Add an Upstream to the endpoint.
  3. Issue a Service Token for the endpoint. Note it down.
  4. Configure your client to use the Blueteam AI endpoint for its LLM API:

Bash / curl

The fastest way to start exercising Blueteam AI is to use the curl command from the command line.

Example

BLUETEAM_ENDPOINT_BASE=https://fmops.ai/api/v1/endpoints/<your_endpoint_name>/openai/v1
BLUETEAM_ENDPOINT_TOKEN=<your_endpoint_service_token>
curl ${BLUETEAM_ENDPOINT_BASE}/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $BLUETEAM_ENDPOINT_TOKEN " \
    -d '{
        "model": "gpt-3.5-turbo",
        "messages": [
            {
                "role": "system",
                "content": "You are a poetic assistant. Tell us a joke."
            }
        ]
    }'

Explanation

OpenAI's API can be accessed using the curl command. The -H flag is used to set the authorization header with the value of the service token. The URL OPENAI_API_URL is the endpoint URL and the API Key is OPENAI_API_KEY.

OPENAI_API_BASE=https://api.openai.com/v1
curl ${OPENAI_API_BASE}/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
        "model": "gpt-3.5-turbo",
        "messages": [
            {
                "role": "system",
                "content": "You are a poetic assistant. Tell us a joke."
            }
        ]
    }'

Blueteam AI is compliant with OpenAI's API and can be swapped out with OpenAI's API URL and API Key. This is done by replacing OPENAI_API_BASE with the Blueteam Endpoint URL and OPENAI_API_KEY with a Service Token from the BlueteamEndpoint.

Note that since we are using the Chat Completions API, the /chat/completions route is appended to the API Base.

Python

To allow reuse and composition, Blueteam AI can be accessed from the Python library openai.

Example

import openai

openai.api_base = "https://fmops.ai/api/v1/endpoints/<your_endpoint_name>/openai/v1"
openai.api_key = "<your_endpoint_service_token>"

Explanation

The Python library openai is used to interact with OpenAI's API. These utilize the same HTTP REST API used in the previous curl example. The api_base and api_key are set to the Blueteam Endpoint URL and Service Token respectively.

Typescript

For front-end applications, TypeScript is a popular choice. Blueteam AI can be accessed from the TypeScript library openai.

const openai = new OpenAIApi(
new Configuration({
apiKey: "<your_endpoint_service_token>",
}),
"https://fmops.ai/api/v1/endpoints/<your_endpoint_name>/openai/v1",
);