Models API Apex Classes
The Models API provides Apex classes that connect your application to large language models (LLMs). To get started, see Access Models API with Apex .
This page lists all the Apex classes that are autogenerated from the Models REST API specification using External Services . The methods for each capability are located within the main ModelsAPI class. The rest of the classes contain property values associated with a request or a response.
The namespace for all Models API classes is aiplatform.
ModelsAPI
The main class for the Models API.
Methods
The methods of the ModelsAPI class are the primary way to interact with the Models API via Apex.
createChatGenerations(...)
Generate a response based on a list of messages representing a chat conversation.
createEmbeddings(...)
Create an embedding vector representing the input text.
createGenerations(...)
Generate a response based on the provided prompt.
submitFeedback(...)
Submit feedback for generated text.
Child Classes
The child classes of the ModelsAPI parent class.
createChatGenerations_Request
Contains the request information for a chat generations request.
createChatGenerations_Response
Contains the response information for a chat generations response.
Property Type Description Code200 ModelsAPI_ChatGenerationsResponse The response information for a successful chat generations response, including the prompt and generated text. responseCode Integer An HTTP status code.
createChatGenerations_ResponseException
An exception for chat generation responses other than Code200. For information on HTTP and status code standards, see RFC 9110 HTTP Semantics .
createGenerations_Request
Contains the request information for a generations request.
createGenerations_Response
Contains the response information for a generations response.
Property Type Description Code200 ModelsAPI_GenerationResponse The response information for a successful chat generations response, including the prompt and generated text. responseCode Integer Response code.
createGenerations_ResponseException
An exception for generation responses other than Code200. For information on HTTP and status code standards, see RFC 9110 HTTP Semantics .
createEmbeddings_Request
Contains the request information for an embeddings request.
createEmbeddings_Response
Contains the response information for an embeddings request.
Property Type Description Code200 ModelsAPI_EmbeddingResponse The response information for a successful embedding response. responseCode Integer An HTTP status code.
createEmbeddings_ResponseException
An exception for embeddings responses other than Code200. For information on HTTP and status code standards, see RFC 9110 HTTP Semantics .
submitFeedback_Request
Contains the request information for a feedback submission.
submitFeedback_Response
The response information for an accepted feedback response.
Property Type Description Code202 ModelsAPI_submitFeedback_OUT_202 The response information for an accepted feedback response. responseCode Integer An HTTP status code.
submitFeedback_ResponseException
An exception for chat feedback responses other than Code200. For information on HTTP and status code standards, see RFC 9110 HTTP Semantics .
ModelsAPI_ChatGenerationsRequest
A chat generation request.
Property Type Description messages List<ModelsAPI_ChatMessageRequest > List of messages to send to the model. These messages should be in chronological order. localization ModelsAPI_Localization Localization information, which can include the default locale, input locale(s), and expected output locale(s). tags ModelsAPI_Tags Entries used by the Models API for non-generative purposes and entries used by the client for free-form data.
ModelsAPI_ChatGenerationsResponse
A chat generation response.
Property Type Description id String Unique identifier for the response. generationDetails ModelsAPI_GenerationDetails Details for a chat generation response.
ModelsAPI_ChatMessage
A message in a conversation. This message is used in a chat generation response.
Property Type Description id String Generation ID. Required to register feedback. role String Persona that sent the message. content String The content of the message. timestamp Long Timestamp when the message was sent. parameters ModelsAPI_ChatMessage_parameters Provider-specific attributes included as part of this object. contentQuality ModelsAPI_ContentTrustRepresentation Content quality details.
ModelsAPI_ChatMessageRequest
A message in a conversation. This message is used in a chat generation request.
Property Type Description role String Persona that sent the message. content String The content of the message.
ModelsAPI_ChatMessage_parameters
Any provider-specific attributes included as part of this object.
Property Type Description properties Map of String, Object Provider-specific properties.
ModelsAPI_ContentModeration
This class is deprecated.
ModelsAPI_ContentTrustRepresentation
Content moderation details for generated content.
ModelsAPI_EmbeddingRequest
An embedding request.
Property Type Description input List<String> Input text used for generating an embedding. Data is encoded as an array of strings. localization ModelsAPI_Localization Localization information, which can include the default locale, input locale(s), and expected output locale(s). tags ModelsAPI_Tags Entries used by the Models API for non-generative purposes and entries used by the client for free-form data.
ModelsAPI_EmbeddingResponse
An embedding response.
ModelsAPI_EmbeddingResponse_parameters
Any provider-specific attributes included as part of this object.
Property Type Description properties Map of String, Object Provider-specific properties.
ModelsAPI_Embeddings
An embedding vector for the text.
Property Type Description embedding List<Double> Embedding of the text. Data is specified as an array of numbers. index Integer Index of the input text to which the embedding belongs.
ModelsAPI_Error
Models API error.
Property Type Description errorCode String Error code to map the error message. messageCode String A specification of the error that uniquely identifies an error message. message String Description of the error. targets List<ModelsAPI_Error_targets > Collection of references representing the specific occurrence of the problem. parameters List<ModelsAPI_Error_parameters > A collection of name-value pairs where each item in the collection represents a parameter leveraged in the error message. properties Map of String, Object A map of the properties.
ModelsAPI_Error_parameters
A collection of name-value pairs where each item in the collection represents a parameter leveraged in the error message.
Property Type Description name String Parameter name. value String Parameter value.
ModelsAPI_Error_targets
Collection of references representing the specific occurrence of the problem.
Property Type Description z0type String Type of the target (FIELD, QUERY_PARAMETER, HTTP_HEADER). reference String Reference to the specific occurrence of the problem.
ModelsAPI_FeedbackRequest
A feedback request.
Property Type Description id String Unique ID for the feedback object. generationId String Identifies the target of this feedback data. You can specify the ID of a /generations response, or use any other identifier as a string value. The Models API doesn’t do any semantic validation on this field. It’s only meant for identifying this information in the datastore. feedback String The feedback sentiment. Can be null. feedbackText String The textual representation of the feedback as provided by the user. source String The source of the feedback. For example, human or app. appFeedback ModelsAPI_FeedbackRequest_appFeedback Dictionary of any app-level feedback and any other free-form parameters. appGenerationId String App-specific generation ID to support cases where the client has multiple responses in a single generation. appGeneration String App-specific generation text to support cases where the client has multiple responses in a single generation.
ModelsAPI_FeedbackRequest_appFeedback
Dictionary of any app-level feedback and any other free-form parameters.
Property Type Description properties Map of String, Object A map of the properties.
ModelsAPI_GenerationDetails
Details for a chat generation response.
ModelsAPI_GenerationDetails_parameters
Any provider-specific attributes included as part of this object.
Property Type Description properties Map of String, Object A map of the properties.
ModelsAPI_GenerationRepresentation
The generated text that is part of the generation response.
ModelsAPI_GenerationRepresentation_parameters
Any provider-specific attributes included as part of this object. Can be null.
Property Type Description properties Map of String, Object A map of the properties.
ModelsAPI_GenerationRequest
A generation request containing prompt, localization, and tag information.
Property Type Description prompt String The prompt or text to be completed. localization ModelsAPI_Localization Localization information, which can include the default locale, input locale(s), and expected output locale(s). tags ModelsAPI_Tags Entries used by the Models API for non-generative purposes and entries used by the client for free-form data.
ModelsAPI_GenerationResponse
A generations response.
ModelsAPI_GenerationResponse_parameters
Any provider-specific attributes included as part of this object. Can be null.
Property Type Description properties Map of String, Object A map of the properties.
ModelsAPI_Localization
Localization information, which can include the default locale, input locale(s), and expected output locale(s). To learn more, see Specify Languages and Locales with Models API .
Property Type Description defaultLocale String Default locale. inputLocales List<ModelsAPI_ProbableLocale > List of language codes or locales found in the prompt. expectedLocales List<String> Expected output languages of the generations. Derived from the output language instructions of the prompt.
ModelsAPI_ProbableLocale
The locale and an optional probability value.
Property Type Description locale String A language or locale. probability Double An estimate of how frequently you expect this language or locale to appear in the input.
ModelsAPI_Tags
Entries used by the Models API for non-generative purposes and entries used by the client for free-form data.
Property Type Description properties Map of String, Object A map of the properties.
ModelsAPI_TrustCategoryDetail
Safety score for a given category.
Property Type Description categoryName String Name of the category. score Double A toxicity score value. A higher score means the response is more likely to be toxic.
ModelsAPI_TrustScannerRepresentation
Represents safety and toxicity data.
Property Type Description isDetected Boolean Indicates whether a scan detected any toxic content. A false value doesn’t necessarily mean that the content isn’t toxic. categories List<ModelsAPI_TrustCategoryDetail > List of safety scores for different categories.
ModelsAPI_submitFeedback_OUT_202
An accepted feedback message.
Property Type Description message String An accepted feedback message.