Skip to content

New Model Platform Integration Guide

← Developer Docs · 简体中文

1. Overview

AIDeepIn uses Strategy Pattern + Factory Pattern + Context Pattern to manage multiple model platforms. The system currently supports the following capability types:

TypeConstantDescriptionIntegration Doc
ChattextText conversation (Chat Completions)Chat Integration
VisionvisionMultimodal conversation (supports image input)Chat Integration
Image GenerationimageText-to-image generationImage Integration
Text-to-SpeechttsText to speechTTS Integration
Speech-to-TextasrSpeech to textASR Integration

Note: Chat (text) and Vision (vision) share the same LLM infrastructure (AbstractLLMService) and use the same integration logic.

Integrating a new platform involves two parts:

  1. Part 1: Database Configuration (Required) — See Section 2 below
  2. Part 2: Code Development (As Needed) — Read the corresponding capability integration doc based on which capabilities you want to enable

Quick Start: If the new platform is compatible with the OpenAI API and you only need Chat (text) or Vision (vision) functionality, simply complete the database configuration — no code required. The system will automatically load the platform's chat models via OpenAiCompatibleLLMService.


2. Database Configuration (Required)

2.1 Model Platform Table (adi_model_platform)

This table stores platform-level configuration (API endpoint, credentials, etc.).

sql
INSERT INTO adi_model_platform (name, title, base_url, api_key, remark, is_proxy_enable, is_openai_api_compatible)
VALUES ('newai', 'NewAI', 'https://api.newai.com/v1', 'your-api-key', 'NewAI model platform', false, true);
FieldTypeDescription
namevarchar(45)Platform unique identifier, e.g. openai, dashscope, ollama. Must match the constant in AdiConstant.ModelPlatform
titlevarchar(45)Display name, e.g. OpenAI, DeepSeek
base_urlvarchar(250)API base URL, e.g. https://api.openai.com/v1
api_keyvarchar(100)API key
secret_keyvarchar(100)Deprecated, kept for compatibility only
remarkvarchar(1000)Remarks
is_proxy_enablebooleanWhether to access via proxy (proxy is configured in application.yml under adi.proxy)
is_openai_api_compatiblebooleanKey field: Whether the platform is compatible with the OpenAI API format. When set to true, chat (text/vision) models will be automatically loaded using OpenAiCompatibleLLMService with no code required

2.2 AI Model Table (adi_ai_model)

This table stores specific model information under a platform. Each capability type corresponds to one record.

sql
-- Chat model
INSERT INTO adi_ai_model (name, title, type, platform, context_window, max_input_tokens, max_output_tokens,
    input_types, response_format_types, is_free, is_enable, properties)
VALUES ('newai-chat-v1', 'NewAI Chat V1', 'text', 'newai', 128000, 120000, 8000,
    'text', 'text,json_object', false, true, '{}');

-- Vision model
INSERT INTO adi_ai_model (name, title, type, platform, context_window, max_input_tokens, max_output_tokens,
    input_types, response_format_types, is_free, is_enable, properties)
VALUES ('newai-vision-v1', 'NewAI Vision V1', 'vision', 'newai', 128000, 120000, 8000,
    'text,image', 'text', false, true, '{}');

-- Image generation model
INSERT INTO adi_ai_model (name, title, type, platform, context_window, max_input_tokens, max_output_tokens,
    input_types, response_format_types, is_free, is_enable, properties)
VALUES ('newai-image-v1', 'NewAI Image V1', 'image', 'newai', 0, 0, 0,
    'text', 'text', false, true, '{}');

-- TTS model
INSERT INTO adi_ai_model (name, title, type, platform, context_window, max_input_tokens, max_output_tokens,
    input_types, response_format_types, is_free, is_enable, properties)
VALUES ('newai-tts-v1', 'NewAI TTS V1', 'tts', 'newai', 0, 0, 0,
    'text', 'text', false, true, '{"voices":["alloy","echo","fable"]}');

-- ASR model
INSERT INTO adi_ai_model (name, title, type, platform, context_window, max_input_tokens, max_output_tokens,
    input_types, response_format_types, is_free, is_enable, properties)
VALUES ('newai-asr-v1', 'NewAI ASR V1', 'asr', 'newai', 0, 0, 0,
    'audio', 'text', false, true, '{}');
FieldTypeDescription
namevarchar(45)Model name, must exactly match the model name specified by the platform provider (passed as API parameter)
titlevarchar(45)Display name
typevarchar(45)Model type: text, image, vision, embedding, rerank, tts, asr
platformvarchar(45)Corresponds to adi_model_platform.name
context_windowintContext window size (token count)
max_input_tokensintMaximum input token count
max_output_tokensintMaximum output token count
input_typesvarchar(100)Supported input types: text, image, audio, video, comma-separated
response_format_typesvarchar(200)Supported output formats: text, json_object, comma-separated
propertiesjsonbModel-specific properties, e.g. TTS voice list {"voices":["v1","v2"]}
settingvarchar(500)Model configuration, JSON format
is_freebooleanWhether the model is free
is_enablebooleanWhether the model is enabled
is_reasonerbooleanWhether the model is a reasoning model (e.g. deepseek-r1)
is_thinking_closablebooleanWhether the thinking process can be disabled (e.g. Qwen3 can, deepseek-r1 cannot)
is_support_web_searchbooleanWhether the model supports web search

2.3 Using the Admin API

Alternatively, you can use the admin backend API instead of executing SQL directly:

  • POST /admin/model-platform/add — Add platform
  • POST /admin/model-platform/edit — Edit platform
  • POST /admin/model/addOne — Add model
  • POST /admin/model/edit — Edit model

3. Debugging & Verification

Check Startup Logs

The service prints model loading logs on startup:

add openai api compatible llm model,model: AiModel(name=newai-chat-v1, ...)
add llm model,model: AiModel(name=newai-chat-v1, ...)
add image model,model: AiModel(name=newai-image-v1, ...)
add tts model,model: AiModel(name=newai-tts-v1, ...)
add asr model,model: AiModel(name=newai-asr-v1, ...)

If you see {platform} service is disabled, it means no models are enabled for that platform or the API Key is not configured.

Common Issues

IssueCauseSolution
Platform not loadedis_deleted = true in adi_model_platformEnsure the record is not soft-deleted
Model not loadedis_enable = false in adi_ai_modelSet is_enable to true
Chat model not working despite is_openai_api_compatible = trueapi_key is emptyConfigure a valid API Key
Non-OpenAI-compatible platform model not workingNot registered in AiModelInitializerAdd registration code per the corresponding capability integration doc
Proxy not workingPlatform is_proxy_enable = false or global proxy disabledCheck adi_model_platform.is_proxy_enable and adi.proxy.enable in application.yml

4. Source Code Index

File PathDescription
adi-common/.../entity/ModelPlatform.javaModel platform entity
adi-common/.../entity/AiModel.javaAI model entity
adi-common/.../cosntant/AdiConstant.javaPlatform name constants (ModelPlatform inner class) + model type constants (ModelType inner class)
adi-common/.../languagemodel/CommonModelService.javaBase class for all services (holds AiModel and ModelPlatform references)
adi-common/.../languagemodel/AbstractLLMService.javaChat service abstract base class
adi-common/.../languagemodel/AbstractImageModelService.javaImage generation abstract base class
adi-common/.../languagemodel/AbstractTtsModelService.javaTTS abstract base class
adi-common/.../languagemodel/AbstractAsrModelService.javaASR abstract base class
adi-common/.../languagemodel/OpenAiCompatibleLLMService.javaOpenAI-compatible platform chat service (auto-loaded)
adi-common/.../service/AiModelInitializer.javaService registration factory (all platforms register here)
adi-common/.../helper/LLMContext.javaChat service context (stores and looks up AbstractLLMService)
adi-common/.../helper/ImageModelContext.javaImage generation service context
adi-common/.../helper/TtsModelContext.javaTTS service context
adi-common/.../helper/AsrModelContext.javaASR service context

Previous: System Architecture · Next: Chat / Vision Integration