---
agentTools:
  projectIndex: https://preemo.readme.io/llms.txt
---

# Complete model

Completes your fine-tuned model with the specified prompt string. The model will generate a completion.

# OpenAPI definition

```json
{
  "externalDocs": {
    "description": "Gradient AI documentation",
    "url": "https://docs.gradient.ai"
  },
  "info": {
    "contact": {
      "email": "support@gradient.ai",
      "name": "Gradient AI Support",
      "url": "https://docs.gradient.ai/discuss"
    },
    "description": "Interface for interacting with Gradient AI.",
    "title": "Gradient AI API",
    "version": "1.0.0"
  },
  "openapi": "3.0.3",
  "security": [
    {
      "AccessToken": []
    }
  ],
  "servers": [
    {
      "description": "Production endpoint",
      "url": "https://api.gradient.ai/api"
    },
    {
      "url": "http://localhost:3026/api"
    }
  ],
  "tags": [
    {
      "description": "Operations related to models.",
      "name": "Models"
    }
  ],
  "x-readme": {
    "samples-languages": [
      "curl",
      "python",
      "node"
    ],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "components": {
    "securitySchemes": {
      "AccessToken": {
        "scheme": "bearer",
        "type": "http"
      }
    },
    "schemas": {
      "CompleteModelSuccess": {
        "type": "object",
        "properties": {
          "finishReason": {
            "type": "string"
          },
          "generatedOutput": {
            "type": "string"
          }
        },
        "required": [
          "finishReason",
          "generatedOutput"
        ]
      },
      "CompleteModelError": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "payload": {
                "type": "object",
                "properties": {
                  "flaggedContent": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sample": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "sample"
                      ]
                    }
                  }
                },
                "required": [
                  "flaggedContent"
                ]
              },
              "type": {
                "type": "string",
                "enum": [
                  "flaggedContent"
                ]
              }
            },
            "required": [
              "message",
              "payload",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "payload": {
                "type": "object",
                "properties": {
                  "formattedValidationError": {
                    "nullable": true
                  },
                  "validationError": {}
                }
              },
              "type": {
                "type": "string",
                "enum": [
                  "bodyParsingError"
                ]
              }
            },
            "required": [
              "message",
              "payload",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "payload": {
                "type": "object",
                "properties": {
                  "formattedValidationError": {
                    "nullable": true
                  },
                  "validationError": {}
                }
              },
              "type": {
                "type": "string",
                "enum": [
                  "queryOrPathParsingError"
                ]
              }
            },
            "required": [
              "message",
              "payload",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "failed"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "modelDoesNotSupportGuidance"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "noRagDocumentsFound"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "ragRequiresAutoTemplating"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "unknownBaseModel"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "unknownModelAdapter"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "unknownRagCollection"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "unprocessableContent"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          }
        ]
      },
      "CompleteModelBodyParams": {
        "type": "object",
        "properties": {
          "autoTemplate": {
            "type": "boolean",
            "nullable": true,
            "default": true,
            "description": "Automatically adds the recommended base model templating."
          },
          "guidance": {
            "type": "object",
            "nullable": true,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "choice"
                ]
              },
              "value": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 32
                },
                "minItems": 1,
                "maxItems": 10,
                "description": "The set of possible values that should be generated by the model"
              }
            },
            "required": [
              "type",
              "value"
            ]
          },
          "maxGeneratedTokenCount": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "exclusiveMinimum": true,
            "maximum": 512,
            "exclusiveMaximum": true,
            "description": "The maximum number of tokens to generate."
          },
          "query": {
            "type": "string",
            "minLength": 1,
            "description": "The prompt string you are providing the model, to which the model will generate a completion in response."
          },
          "rag": {
            "type": "object",
            "nullable": true,
            "properties": {
              "collectionId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID of the RAG collection to retrieve context from before running completion"
              }
            },
            "required": [
              "collectionId"
            ]
          },
          "temperature": {
            "type": "number",
            "nullable": true,
            "description": "This parameter adjusts the degree of randomness in generation. Higher temperature results in more diverse generations."
          },
          "topK": {
            "type": "integer",
            "nullable": true,
            "description": "This parameter ensures that only the top k most likely tokens are considered for generation at each step."
          },
          "topP": {
            "type": "number",
            "nullable": true,
            "description": "This parameter ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If topK is also enabled, topP acts after topK."
          }
        },
        "required": [
          "query"
        ]
      }
    }
  },
  "paths": {
    "/models/{id}/complete": {
      "post": {
        "description": "Completes your fine-tuned model with the specified prompt string. The model will generate a completion.",
        "operationId": "CompleteModel",
        "summary": "Complete model",
        "tags": [
          "Models"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "The ID of the base model or fine-tuned model that is being completed."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "x-gradient-workspace-id",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteModelBodyParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompleteModelSuccess"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompleteModelError"
                }
              }
            }
          }
        }
      }
    }
  },
  "_id": {
    "buffer": {
      "0": 100,
      "1": 201,
      "2": 83,
      "3": 144,
      "4": 228,
      "5": 32,
      "6": 103,
      "7": 0,
      "8": 117,
      "9": 236,
      "10": 84,
      "11": 142
    }
  }
}
```