Adding the x-yc-apigateway-integration:http extension for integration with YandexGPT
-
In the management console
, select the folder in which you created or want to create an API gateway. -
In the list of services, select API Gateway.
-
Select an API gateway or click Create API gateway to create a new one.
-
In the Specification field, click
. -
Specify the following in the field:
- Path: Relative path to the integration that will be added to API Gateway URL. Specify variables in curly braces, e.g.,
/static/{function_id}
. For more information, see the OpenAPI 3.0 specification. - HTTP method: Method that will be used to work with the integration.
-
Service account: Service account for authorization when accessing YandexGPT API. If you do not have a service account, create one.
-
Model URI: URI of the model to use for generation or classification.
-
Action: Action type and parameters matching this action type:
-
Text generation
:- (Optional) Temperature: Determines the variability of the model response: specify a value from
0
to1
. With a higher temperature, you get more creative and randomized response from the model. The default value is0.3
. - (Optional) Number of tokens: Maximum number of generation tokens. The default value is
5
. This allows you to limit the size of the model response, if required.
- (Optional) Temperature: Determines the variability of the model response: specify a value from
-
Text classification
:-
Task description: Text description of the task for the classifier.
-
Classes: List of classes the text can belong to. To add a class, click
.
To get correct results, use meaningful class names. -
(Optional) Request examples: Examples of text requests for classes in
text request:class
format. To add an example, click . For more information, see Few-shot classifier.
-
-
- Path: Relative path to the integration that will be added to API Gateway URL. Specify variables in curly braces, e.g.,
-
Click Add.
The Specification field will display the OpenAPI specification with the specified parameter values.
Requirements to the structure of an incoming request
For the API gateway to correctly process incoming requests, you must set the Content-Type: application/json
header, while the request body must have the following structure:
- Text generation:
{"message": "<text_request_to_model>"}
. - Text classification:
{"text": "<text_to_classify>"}
.