messages-questionLanguage Models

Pick, inspect, and configure language models for your agents. Use this guide when you are selecting models, balancing cost versus latency, or migrating from provider-specific IDs to managed catalog entries.

circle-info

Model coverage per interface lives in the AIP capability matrixarrow-up-right. Highlights: selecting by language_model_id and applying runtime overrides are fully supported via the SDK. CLI flags for some workflows may lag; use export/import or SDK helpers for those flows.

Discover Models

When to use: Inventory available providers or confirm new deployments before routing traffic.

from glaip_sdk import Client

client = Client()
for model in client.list_language_models():
    print(model["id"], model["name"], model.get("provider"))

CLI equivalent:

aip models list

The response includes provider, model name, optional base URL, and any capability flags (context length, streaming support, etc.).

Assign Models to Agents

When to use: Update default models or move from legacy provider/model pairs to catalog-managed IDs.

The SDK supports three ways to specify models, from simplest to most flexible:

Use typed constants for IDE autocomplete, validation, and to avoid typos. These resolve to the standardized provider/model format.

Available constants:

Provider
Import
Examples

OpenAI

from glaip_sdk.models import OpenAI

GPT_5_NANO, GPT_5_MINI, GPT_5, GPT_4O

Anthropic

from glaip_sdk.models import Anthropic

CLAUDE_SONNET_4_0, CLAUDE_OPUS_4_0

Google

from glaip_sdk.models import Google

GEMINI_2_5_FLASH, GEMINI_2_5_PRO

Azure OpenAI

from glaip_sdk.models import AzureOpenAI

GPT_4O, GPT_4O_MINI

DeepInfra

from glaip_sdk.models import DeepInfra

QWEN3_30B_A3B, KIMI_K2_INSTRUCT

DeepSeek

from glaip_sdk.models import DeepSeek

DEEPSEEK_CHAT

AWS Bedrock

from glaip_sdk.models import Bedrock

CLAUDE_SONNET_4_20250514_V1_0

The default model is OpenAI.GPT_5_NANO.

2. String Format (Direct)

Use the standardized provider/model format directly as a string. Use this when you need a model not in the constants, or when working in environments without IDE support.

circle-info

Format patterns:

  • OpenAI: openai/<model>openai/gpt-5, openai/gpt-4o

  • DeepInfra: deepinfra/<org>/<model>deepinfra/Qwen/Qwen3-30B-A3B

  • DeepSeek: deepseek/<org>/<model>deepseek/deepseek-ai/DeepSeek-V3.1

  • Anthropic: anthropic/<model>anthropic/claude-sonnet-4-0

  • Google: google/<model>google/gemini-2.5-flash

  • Azure OpenAI: azure-openai/<model>azure-openai/gpt-4o

Invalid formats (missing /) raise a ValueError with suggestions to use model constants.

Common routing issues

Symptom
Likely cause
Fix

Agent still uses the old model

Cached agent config or CLI not updated.

Re-run aip agents update and confirm the agent payload includes the new language_model_id.

400 Unknown model errors

Model ID not available in the target environment.

List models in that environment or request the provider be deployed there.

High latency after switching models

New model has different performance profile.

Adjust timeout_seconds in agent_config for latency-sensitive runs.

Streaming stops mid-response

Model lacks streaming support.

Disable streaming for that agent or choose a streaming-capable model.

Advanced: Custom Model Configuration

For custom endpoints, credentials, and hyperparameters not covered by the standard format, use the Model class:

circle-info

Model Configuration Breakdown:

  • id: Model identifier in provider/model format. Use "custom/<name>" for custom providers not in built-in constants.

  • base_url: The API endpoint URL for the model provider (e.g., "https://api.moonshot.ai/v1").

  • credentials: API key as a string, or a dict with additional credential fields.

  • hyperparameters: Model-specific parameters like temperature, max_tokens, top_p, etc.

Custom DeepInfra Model with Credentials

circle-exclamation

Local vs Remote Execution

When to use: Understand how model configuration behaves when switching between local execution (via agent.run()) and remote execution (via agent.deploy() and server-side runs).

How Model Configuration Works

Execution Mode
Model Configuration
Behavior

Local (agent.run())

Model object with base_url, credentials, hyperparameters

Full configuration is used directly by aip_agents

Local

String like "deepinfra/Qwen/Qwen3-30B-A3B"

SDK resolves base_url from built-in provider mappings; credentials from env vars

Remote (agent.deploy())

Model object or string

Agent is deployed to AIP server; server uses its configured language_model_id mappings

Remote

language_model_id="uuid"

Server looks up model in its catalog; ignores local config

Example: Local Execution with AIP Server Models

When a model exists on the AIP server (has a language_model_id), you can still use it locally:

circle-info

Built-in Provider Configurations: The SDK includes default base_url mappings for:

  • deepinfrahttps://api.deepinfra.com/v1/openai

  • deepseekhttps://api.deepseek.com

For these providers, you only need to set the corresponding environment variable (DEEPINFRA_API_KEY, DEEPSEEK_API_KEY) or pass credentials explicitly.

Example: Custom Model Not in AIP Server

For models not configured on the AIP server, use the Model class with full configuration:

Switching Between Local and Remote

When you call agent.deploy(), the agent is synchronized with the AIP server. The server manages its own model catalog via language_model_id mappings:

circle-exclamation

Using Custom Models with AIP Server

When to use: You want to use a custom model in remote execution (via agent.deploy()) that's not in the AIP server's catalog.

For models not in the AIP server catalog, the simplest approach is to use local execution with the Model class:

This works immediately without any server-side configuration. The SDK passes your credentials and configuration directly to the local runner.

Option 2: Register Model on AIP Server

To use a custom model in remote execution (via agent.deploy()), the model must be registered on the AIP server first.

Check available models:

Register a new model:

The CLI does not currently support creating language models directly. You have two options:

Option A: Use the REST API (requires admin/master API key)

circle-info

Required fields:

  • provider: Provider identifier (e.g., "custom", "openai-compatible")

  • name: Model name identifier

Optional fields:

  • base_url: API endpoint URL for the provider

  • credentials: API key or authentication token

  • hyperparameters: Default hyperparameters like temperature, max_tokens, etc.

  • capabilities: Feature flags (streaming, function calling, etc.) - configured server-side

  • context_length: Maximum context window size - configured server-side

Option B: Ask your admin to register the model with details like:

  • provider: Provider identifier (e.g., "custom", "openai-compatible")

  • name: Model name (e.g., "kimi-k2.5")

  • base_url: API endpoint URL (e.g., "https://api.moonshot.ai/v1")

  • credentials: API key for authentication

  • hyperparameters: Default model settings (optional)

Once registered, you can use the model by name in remote execution:

circle-info

When to register on server:

  • You need remote execution (running agents on AIP server infrastructure)

  • You want to share the model across your team without sharing API keys

  • You want centralized credential management (API keys stored on server, not locally)

When to use local execution:

  • Quick prototyping and testing

  • Models with local-only access or custom endpoints

  • When you don't have admin access to register models

Last updated

Was this helpful?