> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memmachine.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Language Model Endpoint

> Add a new language model configuration at runtime.

    Creates a new language model with the specified configuration and attempts
    to initialize it immediately. This allows adding models without restarting
    the server. The configuration is persisted to the configuration file.

    **Security Warning**: API keys and credentials are stored in plain text in
    the configuration file. Only use this API in protected environments. To
    avoid storing secrets in plain text, use environment variable references
    (e.g., `"api_key": "$OPENAI_API_KEY"`) which will be resolved at runtime.

    Supported providers:
    - `openai-responses`: OpenAI models using the Responses API (requires api_key, model)
    - `openai-chat-completions`: OpenAI models using Chat Completions API (requires api_key, model)
    - `amazon-bedrock`: AWS Bedrock models (requires region, model_id)

    The response indicates whether the model was successfully initialized:
    - `success: true, status: ready`: Model is available for use
    - `success: false, status: failed`: Initialization failed (check error field)

    If initialization fails, the model configuration is still stored and can
    be retried later using the retry endpoint when the underlying service
    becomes available.

    Returns 422 if the provider type or configuration is invalid.



## OpenAPI

````yaml /openapi.json post /api/v2/config/resources/language_models
openapi: 3.1.0
info:
  title: MemMachine API
  version: 0.3.10
  description: >-
    Architectural Memory Systems for AI Agents. Specialized in episodic and
    semantic memory management with strict namespace isolation.
servers:
  - url: http://localhost:8080
security: []
tags:
  - name: Configuration
    description: System overview and memory subsystem configuration.
  - name: Episodic Configuration
    description: Per-project episodic memory subsystem configuration.
  - name: Memories
    description: Core operations for episodic and semantic memory ingestion and retrieval.
  - name: Projects
    description: Lifecycle management for isolated memory namespaces.
  - name: Resources
    description: Embedder, language model, and reranker lifecycle management.
  - name: 'Semantic Memory: Categories'
    description: Category, template, and tag management for semantic sets.
  - name: 'Semantic Memory: Features'
    description: Add, retrieve, and update individual semantic features.
  - name: 'Semantic Memory: Sets'
    description: Set type and set ID lifecycle, listing, and configuration.
  - name: System
    description: Infrastructure, health, and observability.
paths:
  /api/v2/config/resources/language_models:
    post:
      tags:
        - Resources
      summary: Add Language Model Endpoint
      description: |-
        Add a new language model configuration at runtime.

            Creates a new language model with the specified configuration and attempts
            to initialize it immediately. This allows adding models without restarting
            the server. The configuration is persisted to the configuration file.

            **Security Warning**: API keys and credentials are stored in plain text in
            the configuration file. Only use this API in protected environments. To
            avoid storing secrets in plain text, use environment variable references
            (e.g., `"api_key": "$OPENAI_API_KEY"`) which will be resolved at runtime.

            Supported providers:
            - `openai-responses`: OpenAI models using the Responses API (requires api_key, model)
            - `openai-chat-completions`: OpenAI models using Chat Completions API (requires api_key, model)
            - `amazon-bedrock`: AWS Bedrock models (requires region, model_id)

            The response indicates whether the model was successfully initialized:
            - `success: true, status: ready`: Model is available for use
            - `success: false, status: failed`: Initialization failed (check error field)

            If initialization fails, the model configuration is still stored and can
            be retried later using the retry endpoint when the underlying service
            becomes available.

            Returns 422 if the provider type or configuration is invalid.
      operationId: add_language_model
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddLanguageModelSpec'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateResourceResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AddLanguageModelSpec:
      properties:
        name:
          type: string
          title: Name
          description: |2-

                Unique name/identifier for the language model.
        provider:
          type: string
          enum:
            - openai-responses
            - openai-chat-completions
            - amazon-bedrock
          title: Provider
          description: |2-

                The language model provider type (e.g., 'openai-responses', 'openai-chat-completions', 'amazon-bedrock').
        config:
          additionalProperties: true
          type: object
          title: Config
          description: |2-

                Provider-specific configuration settings.
      type: object
      required:
        - name
        - provider
        - config
      title: AddLanguageModelSpec
      description: Specification for adding a new language model.
    UpdateResourceResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: |2-

                Whether the operation succeeded.
        status:
          $ref: '#/components/schemas/ResourceStatus'
          description: |2-

                Current status of the resource after the operation.
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: |2-

                Error message if the operation failed.
      type: object
      required:
        - success
        - status
      title: UpdateResourceResponse
      description: Response model for resource update operations.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ResourceStatus:
      type: string
      enum:
        - ready
        - failed
        - pending
      title: ResourceStatus
      description: Status of a resource.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````