Adding the x-yc-apigateway-integration:http extension for integration with YandexGPT API
-
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.
- Path: Relative path to the integration that will be added to API Gateway URL. Specify variables in curly braces, e.g.,
-
Under Model used select a model and provide the following:
- For a
YandexGPT
model: Folder ID that will be specified in the YandexGPT API URI. - For a
DataSphere
model: ID of the model tuned in Yandex DataSphere.
- For a
-
Under Prompt delivery method, select a prompt source and specify the following:
- For the
Query parameter
source: Name of the query parameter used to deliver the prompt for the YandexGPT API request. - For the
Request body
source: Name of the request body field used to deliver the prompt for the YandexGPT API request.
- For the
-
Under Use case, select the model use case and set the relevant parameters:
-
Text generation
:- (Optional) Temperature: Determines the variability of the model's response. Specify a value from
0
to1
. With a higher temperature, you get more creative and randomized response from the model. Default value:0.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's 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.
-
-
-
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, set the Content-Type: application/json
header. Plus, consider the following:
-
If
Query parameter
is selected as a method to deliver the prompt, the request must include the query parameter from the Prompt delivery method section and its value.Here is a gateway call path example:
<path_to_integration>?<specified_query_parameter>=<prompt_contents>
. -
If
Request body
is selected as a method to deliver the prompt, the request body must include the field from the Prompt delivery method section and its value.Here is a request body example:
{"<request_body_field_name>": "<prompt_contents>"}
.