YandexGPT icon

YandexGPT

Interact with YandexGPT API for text generation and chat completions

Actions2

Overview

This node integrates with the YandexGPT API to generate text completions based on a given prompt. It supports two main resources: chat-based completions and plain text generation. For the Text - Generate operation, it sends a user-provided prompt to the selected YandexGPT model and returns the generated completion.

Common scenarios for this node include:

  • Automatically generating content such as articles, summaries, or creative writing.
  • Producing responses or suggestions based on a textual prompt.
  • Enhancing workflows that require AI-generated text outputs.

For example, you could use this node to generate product descriptions from short prompts or create chatbot replies in an automated pipeline.

Properties

Name Meaning
Model The YandexGPT model to use for text generation. Options:
- YandexGPT Lite (faster, economical)
- YandexGPT (higher quality)
- YandexGPT Pro (latest enhanced capabilities)
Prompt The input text prompt for which the node will generate a completion.
Temperature Controls randomness of the output; higher values produce more varied and creative results. Range: 0 to 1. Default is 0.6.
Max Tokens Maximum number of tokens to generate in the completion. Range: 1 to 8000. Default is 2000.
Options Additional options collection:
- Stream (boolean): Whether to stream partial progress back during generation. Default is false.

Output

The node outputs an array of JSON objects, each containing:

  • message: The generated text message object returned by YandexGPT, including the generated text under message.text.
  • usage: Information about token usage for the request.
  • modelVersion: The version of the model used for generation.
  • input: Echoes back the input parameters used (messages array, model, temperature, maxTokens).

The output does not include binary data.

Example output JSON snippet:

{
  "message": {
    "role": "assistant",
    "text": "Generated completion text here..."
  },
  "usage": {
    "promptTokens": 10,
    "completionTokens": 50,
    "totalTokens": 60
  },
  "modelVersion": "some-version-string",
  "input": {
    "messages": [
      {
        "role": "user",
        "text": "Your prompt text"
      }
    ],
    "model": "yandexgpt-lite",
    "temperature": 0.6,
    "maxTokens": 2000
  }
}

Dependencies

  • Requires an API key credential for authenticating with the YandexGPT API.
  • Needs configuration of the API endpoint URL and folder ID within the credentials.
  • Uses an IAM token obtained via helper functions for authorization.
  • Relies on HTTP requests to the Yandex Foundation Models API endpoint /foundationModels/v1/completion.

Troubleshooting

  • No messages provided: If the prompt or messages array is empty, the node throws an error indicating no messages were provided. Ensure the prompt property is filled.
  • Invalid response from YandexGPT API: This error occurs if the API response lacks expected fields like result.alternatives. Check API credentials and endpoint correctness.
  • Completion failed with status: If the returned completion status is not final, the node throws an error with the status message. This may indicate incomplete or failed generation.
  • Authentication errors: Issues obtaining the IAM token or invalid API keys will cause failures. Verify credentials and permissions.
  • Streaming option: If enabled, ensure your workflow can handle streamed partial results properly.

Links and References

Discussion