> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://nemo-platform.docs.buildwithfern.com/nemo/platform/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://nemo-platform.docs.buildwithfern.com/nemo/platform/_mcp/server.

# Update VirtualModel

PATCH https://host.com/apis/inference-gateway/v2/workspaces/{workspace}/virtual-models/{name}
Content-Type: application/json

Partially update a VirtualModel.

Only fields present in the request body are modified.  Fields absent from
the request body retain their current values.

Reference: https://nemo-platform.docs.buildwithfern.com/nemo/platform/nemo/platform/documentation/reference/api-reference/virtual-models/update-virtual-model

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Nemo Platform API
  version: 1.0.0
paths:
  /apis/inference-gateway/v2/workspaces/{workspace}/virtual-models/{name}:
    patch:
      operationId: update-virtual-model
      summary: Update VirtualModel
      description: >-
        Partially update a VirtualModel.


        Only fields present in the request body are modified.  Fields absent
        from

        the request body retain their current values.
      tags:
        - subpackage_virtualModels
      parameters:
        - name: workspace
          in: path
          required: true
          schema:
            type: string
        - name: name
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Updated virtual model
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VirtualModel'
        '404':
          description: VirtualModel not found.
          content:
            application/json:
              schema:
                description: Any type
        '409':
          description: Concurrent modification conflict.
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateVirtualModelRequest'
servers:
  - url: https://host.com
    description: Default
components:
  schemas:
    BackendFormat:
      type: string
      enum:
        - OPENAI_CHAT
        - ANTHROPIC_MESSAGES
      description: >-
        Inference backend API wire formats understood by IGW and middleware
        plugins.
      title: BackendFormat
    VirtualModelInferenceConfig:
      type: object
      properties:
        model:
          type: string
        backend_format:
          oneOf:
            - $ref: '#/components/schemas/BackendFormat'
            - type: 'null'
          description: Optional backend format override for this VirtualModel entry.
      required:
        - model
      description: >-
        Inference configuration for one model entity referenced by a
        VirtualModel.
      title: VirtualModelInferenceConfig
    MiddlewareCall:
      type: object
      properties:
        name:
          type: string
        config_type:
          type: string
        config:
          type: object
          additionalProperties:
            description: Any type
        config_id:
          type: string
      required:
        - name
        - config_type
      description: >-
        One entry in a VirtualModel middleware pipeline.


        Declares which plugin to invoke and how to resolve its configuration.

        Exactly one of ``config`` (inline dict) or ``config_id`` (entity
        reference)

        should be provided. ``config_type`` is always required regardless of
        which

        is used — it is the discriminator that tells IGW (and the plugin) which

        config schema applies.


        Attributes:
            name: The entry-point key of the plugin to invoke
                (e.g. ``"nemo-switchyard"``). Must match the plugin's
                ``nemo.inference_middleware`` entry-point key.
            config_type: Always required. Maps to the ``entity_type`` of the plugin's
                config ``NemoEntity`` subclass (e.g. ``"routellm_config"``). Used by
                IGW to call :meth:`~NemoInferenceMiddleware.validate_middleware_config`
                with the right discriminator, and by the plugin to dispatch to the
                correct schema when it supports multiple config types.
            config: Inline config dict. Mutually exclusive with ``config_id``.
            config_id: ``"workspace/name"`` reference to a stored config entity.
                Mutually exclusive with ``config``. IGW resolves this by calling
                :meth:`~NemoInferenceMiddleware.get_middleware_config` on the plugin.
      title: MiddlewareCall
    UpdateVirtualModelRequest:
      type: object
      properties:
        default_model_entity:
          type: string
          description: >-
            Model entity to route to, in "workspace/name" format. Written into
            request["model"] before the request middleware pipeline runs. If
            omitted, a request middleware plugin must handle backend routing
            itself. Set to null to clear an existing value.
        autoprovisioned:
          type: boolean
          default: false
          description: >-
            Marks this VirtualModel as controller-managed. The Models controller
            will delete it once no ModelProvider serves the matching entity.
            Setting this manually opts the VirtualModel into that cleanup
            behavior.
        models:
          type: array
          items:
            $ref: '#/components/schemas/VirtualModelInferenceConfig'
          description: >-
            Model entity references used by this VirtualModel. A per-entry
            backend_format overrides the referenced ModelEntity backend_format
            when IGW resolves the backend format for a request.
        request_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          description: >-
            Ordered list of middleware plugins applied before proxying to the
            backend. Each entry is a MiddlewareCall with a "name" (plugin
            identifier) and optional "config_type" and "config_id" fields that
            reference a stored plugin configuration.
        response_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          description: >-
            Ordered list of middleware plugins applied after the backend
            response is received, before returning it to the caller.
        post_response_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          description: >-
            Ordered list of middleware plugins invoked after the response has
            been returned to the caller. Intended for fire-and-forget work
            (logging, analytics) that must not block or modify the response.
        override_proxy:
          type: string
          description: >-
            Plugin-provided proxy implementation for IGW to use instead of its
            default aiohttp proxy. Format: "plugin-name.proxy-name". Leave unset
            to use the default IGW proxy. Set to null to clear an existing
            value.
      description: >-
        Request body for partially updating an existing VirtualModel (PATCH).


        Only fields present in the request body are updated.  Omitted fields

        retain their current values.  ``model_fields_set`` is used in the
        handler

        to distinguish an intentional ``[]`` (clear the list) from a missing
        field

        (leave unchanged).  Set ``default_model_entity`` or ``override_proxy``
        to

        ``null`` explicitly to clear them.
      title: UpdateVirtualModelRequest
    VirtualModel:
      type: object
      properties:
        name:
          type: string
          default: ''
          description: Entity name within the workspace
        workspace:
          type: string
          description: Workspace identifier
        project:
          type: string
          description: The name of the project associated with this entity.
        default_model_entity:
          type: string
        autoprovisioned:
          type: boolean
          default: false
          description: >-
            Marks this VirtualModel as controller-managed. The Models controller
            will delete it once no ModelProvider serves the matching entity.
            Setting this manually opts the VirtualModel into that cleanup
            behavior.
        models:
          type: array
          items:
            $ref: '#/components/schemas/VirtualModelInferenceConfig'
        request_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          default: []
        response_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          default: []
        post_response_middleware:
          type: array
          items:
            $ref: '#/components/schemas/MiddlewareCall'
          default: []
        override_proxy:
          type: string
        id:
          type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type:
            - string
            - 'null'
        updated_at:
          type: string
          format: date-time
        updated_by:
          type:
            - string
            - 'null'
        entity_id:
          type: string
          description: Alias for id for backwards compatibility.
        parent:
          type: string
          description: Parent entity ID for nested entities.
      required:
        - workspace
        - id
        - created_at
        - created_by
        - updated_at
        - updated_by
        - entity_id
        - parent
      description: >-
        Logical inference route.


        Maps a user-facing model name to an optional default model entity and

        defines ordered middleware pipelines for the request, response, and

        post-response phases.


        When a caller sets ``model: "workspace/my-virtual-model"`` in an
        inference

        request, IGW resolves the ``VirtualModel`` instead of a ``ModelEntity``

        directly. If ``default_model_entity`` is set, IGW writes it into

        ``request["model"]`` before the request middleware pipeline runs.
        Middleware

        may mutate ``request["model"]`` freely. After the pipeline completes,
        IGW

        reads ``request["model"]``, resolves it to a ``ModelProvider`` via the

        ``ModelCache``, and proxies.


        The ``ModelProviderReconciler`` auto-creates a passthrough
        ``VirtualModel``

        for each discovered model (same workspace and name as the
        ``ModelEntity``,

        empty middleware lists, ``default_model_entity`` pointing to that
        entity).

        All existing inference requests continue to work without changes.
      title: VirtualModel

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "workspace": "enterprise-ai",
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "created_at": "2024-01-15T09:30:00Z",
  "created_by": "admin-user",
  "updated_at": "2024-01-15T09:30:00Z",
  "updated_by": "admin-user",
  "entity_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "parent": "root-entity",
  "name": "customer-support-bot",
  "project": "customer-engagement",
  "default_model_entity": "enterprise-ai/gpt-4-chat",
  "autoprovisioned": false,
  "models": [
    {
      "model": "enterprise-ai/gpt-4-chat",
      "backend_format": "OPENAI_CHAT"
    }
  ],
  "request_middleware": [
    {
      "name": "authenticator",
      "config_type": "auth_config",
      "config": {},
      "config_id": "enterprise-ai/auth-config-01"
    }
  ],
  "response_middleware": [
    {
      "name": "response-logger",
      "config_type": "logging_config",
      "config": {},
      "config_id": "enterprise-ai/logging-config-01"
    }
  ],
  "post_response_middleware": [
    {
      "name": "analytics-tracker",
      "config_type": "analytics_config",
      "config": {},
      "config_id": "enterprise-ai/analytics-config-01"
    }
  ],
  "override_proxy": "custom-proxy.v1"
}
```

**SDK Code**

```python
import requests

url = "https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name"

payload = {}
headers = {"Content-Type": "application/json"}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name';
const options = {method: 'PATCH', headers: {'Content-Type': 'application/json'}, body: '{}'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://host.com/apis/inference-gateway/v2/workspaces/workspace/virtual-models/name")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```