Generate Text with GigaChat SDK
Direct Python integration guide for the official GigaChat SDK - sync/async chat, streaming, message history, tokens, session caching.
Why it matters
Leverage the GigaChat Python SDK to integrate powerful text generation capabilities into your applications. This asset enables synchronous and asynchronous chat interactions, including streaming responses, with fine-grained control over model parameters.
Outcomes
What it gets done
Perform text generation using GigaChat.
Implement sync and async chat functionalities.
Enable streaming of generated text.
Configure GigaChat model parameters.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/gigachat-sdk-chat | bash Overview
GigaChat SDK Chat
Guides direct Python integration with the official gigachat SDK for text generation - client setup, sync/async/streaming chat calls, message history, model selection, token counting, and session caching via X-Session-ID. Use it when writing Python code directly against the gigachat package, not LangChain or a proxy layer. Confirm setup first via gigachat-setup, and use the sibling skills for tool/function calling or file and embedding work instead of this one.
What it does
GigaChat SDK Chat is a focused reference for direct Python integration with the official gigachat package's chat capabilities - client initialization via GigaChat(...), synchronous and asynchronous calls (chat, achat), and their streaming counterparts (stream, astream), plus message history and roles, model selection, token counting, and session caching through the X-Session-ID header.
When to use - and when NOT to
Use it specifically when writing Python code that talks to the gigachat package directly, without LangChain or a proxy compatibility layer in between. Before using it, the skill's own workflow says to confirm setup is already solved - falling back to the gigachat-setup skill if not - and to prefer the official SDK over raw HTTP calls unless the user explicitly asks for REST. It deliberately stays out of two adjacent areas: custom tool/function calling, which belongs to gigachat-sdk-functions, and file or embedding handling, which belongs to gigachat-sdk-files-embeddings.
Inputs and outputs
The recommended default is to start simple: for stateless chat, pass a plain string; only build an explicit Chat(messages=[...]) payload when conversation history or a richer message structure is actually needed. Streaming (stream/astream) is recommended for incremental UX, while async variants (achat/astream) should only be reached for when real concurrency is needed - not by default. Before large or cost-sensitive prompts, the skill calls for checking tokens_count first. Two reference files back these patterns with more depth: references/chat.md for request patterns and streaming, and references/models-and-tokens.md for model choice, token counting, context caching, and retries.
Integrations
This skill is one piece of a small GigaChat skill family sharing the same source repository: gigachat-setup for initial configuration, gigachat-sdk-functions for tool/function calling, and gigachat-sdk-files-embeddings for files and embeddings - each intentionally out of scope here so the chat-focused guidance stays uncluttered. Session state is preserved across calls via the X-Session-ID header rather than resending full history every time.
Who it's for
Python developers building directly on top of the official gigachat SDK - rather than through LangChain or an OpenAI-compatible proxy - who want the simplest correct pattern for a given chat use case (sync vs. async, streaming vs. not, stateless vs. history-aware) instead of guessing at the SDK's API shape.
Source README
GigaChat SDK Chat
Use this skill for direct Python integration with gigachat.
What this skill covers
GigaChat(...)client initializationchat,achat,stream,astream- message history and roles
- model selection
- token counting
- session caching with
X-Session-ID - practical error handling and retries
Workflow
- Confirm setup is already solved. If not, use
gigachat-setup. - Prefer the official SDK over raw HTTP unless the user specifically asks for REST calls.
- For stateless chat, pass a simple string.
- For context, build an explicit
Chat(messages=[...])payload. - Use streaming for incremental UX.
- Use async only when concurrency is actually needed.
- Use
tokens_countbefore large prompts or cost-sensitive operations. - Prefer the simplest verified payload shape over inventing a more complex one.
Read these references as needed
- For request patterns and streaming:
references/chat.md - For models, tokens, context caching, and retries:
references/models-and-tokens.md
Default output
- give the user the simplest working SDK pattern first
- use
Chat(messages=[...])only when history or richer payloads are needed - keep starter code minimal unless the user asks for a richer production pattern
Boundaries
- Do not document custom tools or built-in functions here; use
gigachat-sdk-functions. - Do not document files or embeddings here; use
gigachat-sdk-files-embeddings.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.