Adding the x-yc-apigateway-integration:http extension for integration with the Yandex AI Studio text generation API
-
In the management console
, select the folder in which you created or want to create an API gateway. -
From 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
. -
In the field, specify the following:
- Path: Integration relative path to add to the API Gateway URL. Remember to wrap variables in braces, e.g.,
/static/{function_id}. For more information, see the OpenAPI 3.0 specification. - HTTP method: Method to use to work with the integration.
- Service account: Service account for authorization when accessing the text generation API. If you do not have a service account, create one.
- Path: Integration relative path to add to the API Gateway URL. Remember to wrap variables in braces, e.g.,
-
Under Model in use, select a model and specify:
- For a
YandexGPTmodel: Folder ID that will be specified in the text generation model URI. - For a
DataSpheremodel: ID of the model tuned in Yandex DataSphere.
- For a
-
Under Prompt transmission method, select a prompt source and specify the following:
- For the
Query parametersource: Name of the query parameter where you will provide the prompt for the text generation API request. - For the
Body of requestsource: Name of the request body field you will use to provide the prompt for the text generation API request.
- For the
-
Under Usage scenarios, select the model use case and set the relevant parameters:
-
Text generation:- Temperature: Determines the variability of the model's response. This is an optional setting. Specify a value between
0and1. With a higher temperature, you get a more creative and randomized response from the model. The default value is0.3. - Optionally, Number of tokens: Maximum number of generation tokens. The default is
5. This allows you to limit the size of the model response, if required.
- Temperature: Determines the variability of the model's response. This is an optional setting. Specify a value between
-
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.
-
Optionally, Example requests: Examples of text requests for classes in
text request:classformat. 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 Content-Type: application/json. Plus, consider the following:
-
If
Query parameteris selected as a method to deliver the prompt, the request must include the query parameter from the Prompt transmission method section and its value.Here is an API gateway call path example:
<path_to_integration>?<specified_query_parameter>=<prompt_contents>. -
If
Request bodyis selected as a method to deliver the prompt, the request body must include the field from the Prompt transmission method section and its value.Request body example:
{"<request_body_field_name_>": "<prompt_contents>"}.