Spotfire® Server and Environment - Installation and Administration

Adding and configuring AI models using commands

This topic includes examples of how you can add and configure AI models using CLI commands.

Before you begin

See Managing AI models for a list of prerequisites.

Add a model

The example below adds an AI model using the add-ai-model command.

config add-ai-model 
 --bootstrap-config="<bootstrap.xml>"
 --name="OpenAI GPT-4o"
 --model="gpt-4o"
 --api="OpenAi"
 --mode="Completion"
 --api-base="https://api.openai.com"
 --auth-type="ApiKey"
 --api-key="<api-key>"
 --user="<admin-user>"

Add a model with restricted access

The example below adds an AI model using the add-ai-model command, while also restricting access to a group and a user.
config add-ai-model
  --bootstrap-config="<bootstrap.xml>"
  --name="Finance assistant"
  --model="gpt-4o"
  --api="OpenAi"
  --api-base="https://api.openai.com"
  --auth-type="ApiKey"
  --api-key="<api-key>"
  --allowed-group="Finance Authors"
  --allowed-user="alice@example.com"
  --user="<admin-user>"

Update a model

The example below updates an AI model using the update-ai-model command.
config update-ai-model
  --bootstrap-config="<bootstrap.xml>"
  --id="<model-id>"
  --api-base="https://api.openai.com"
  --api-key="<new-api-key>"
  --enable
  --user="<admin-user>"

Review current configurations

The example below shows how you can retrieve and display the AI model configurations using the list-ai-models command.
config list-ai-models
  --bootstrap-config="<bootstrap.xml>"
  --user="<admin-user>"

Add a model with a custom header

The example below adds an AI model with a custom header, using the add-ai-model command.
config add-ai-model
--bootstrap-config="<bootstrap.xml>"
--name="Gateway protected model"
--model="gpt-4o"
--api="OpenAi"
--api-base="https://api.openai.com"
--auth-type="ApiKey"
--api-key=""
"-HX-Spotfire-User=${username}"
"-HX-Spotfire-Request=${requestId}"
--user=""

Add a model that uses a custom authorization header

The example below adds an AI model with a custom authorization header, using the add-ai-model command.
config add-ai-model
--bootstrap-config="<bootstrap.xml>"
--name="Gateway with x-api-key"
--model="gateway-model"
--api="OpenAi"
--api-base="https://gateway.example.com/llm"
--auth-type="ApiKey"
--api-key=""
--auth-header-mode="Custom"
--auth-header="x-api-key"
--user=""

Add an unauthenticated local Ollama model

The example below adds an unauthenticated local Ollama model, using the add-ai-model command.
config add-ai-model
--bootstrap-config="<bootstrap.xml>"
--name="Local Ollama llama3.1"
--model="llama3.1"
--api="Ollama"
--api-base="http://localhost:11434"
--auth-type="None"
--user=""

Update custom headers on an existing model

The example below updates custom headers on an existing AI model using the update-ai-model command.
config update-ai-model
--bootstrap-config="<bootstrap.xml>"
--id=""
"-HX-Spotfire-User=${username}"
"-HX-Spotfire-Request=${requestId}"
-rOld-Header
--user=""