mit einem Klick
twilight-ai
// Assist with development in the Twilight AI Go SDK. Use when working in this repository, adding or updating providers, embeddings, tool calling, streaming, examples, or docs for Twilight AI.
// Assist with development in the Twilight AI Go SDK. Use when working in this repository, adding or updating providers, embeddings, tool calling, streaming, examples, or docs for Twilight AI.
| name | twilight-ai |
| description | Assist with development in the Twilight AI Go SDK. Use when working in this repository, adding or updating providers, embeddings, tool calling, streaming, examples, or docs for Twilight AI. |
Use this skill when the task involves twilight-ai, especially:
sdk/provider/GenerateText, GenerateTextResult, StreamText, Embed, or EmbedManyTwilight AI is a lightweight Go AI SDK with a provider-agnostic core API.
sdk.GenerateText, sdk.GenerateTextResult, sdk.StreamTextsdk.Embed, sdk.EmbedManysdk.Tool, sdk.NewTool[T], WithMaxSteps, approval flowsdk.CreateMCPClient, sdk.MCPClient, sdk.MCPClientConfigStreamPart events over Go channelsprovider/openai/completionsprovider/openai/responsesprovider/anthropic/messagesprovider/google/generativeaiprovider/openai/embeddingprovider/google/embeddingPrefer the high-level SDK API first, then drop to provider details only when needed.
sdk.Model binds a chat model to a sdk.Providersdk.EmbeddingModel binds an embedding model to an sdk.EmbeddingProvidersdk.Tool valuesChoose the narrowest API that matches the task:
sdk.GenerateTextsdk.GenerateTextResultsdk.StreamTextsdk.Embedsdk.EmbedManyIf the task introduces examples or docs, prefer simple end-to-end snippets that start with:
openai/completions for broad OpenAI-compatible support such as DeepSeek, Groq, Ollama, Azure-style compatible endpoints, and generic /chat/completions backends.openai/responses when the task needs OpenAI Responses API features such as first-class reasoning models, reasoning summaries, URL citation annotations, or flat input mapping.anthropic/messages for Claude and Anthropic extended thinking via WithThinking.google/generativeai for Gemini chat, tool calling, vision, streaming, and Gemini reasoning.openai/embedding or google/embedding for embeddings. Keep embedding-provider work separate from chat-provider work.If adding or changing a chat provider, preserve the sdk.Provider contract:
Name()ListModels(ctx)Test(ctx)TestModel(ctx, modelID)DoGenerate(ctx, params)DoStream(ctx, params)Keep provider responsibilities focused:
sdk.GenerateResultsdk.StreamPart valuesEmbedding providers are separate from chat providers. Use sdk.EmbeddingProvider and return an sdk.EmbeddingModel via EmbeddingModel(id).
When updating embeddings:
sdk.Embed for single-string conveniencesdk.EmbedMany for batched requestsUsage.TokensPrefer sdk.NewTool[T] for new tool examples and integrations. It gives typed input and inferred JSON Schema.
Use these defaults unless the task requires something else:
WithToolChoice("auto") for normal useWithMaxSteps(0) for inspection-only tool callsWithMaxSteps(N) for automatic execution loopsRequireApproval: true only for sensitive side effectsWhen streaming with tools, ensure the implementation can emit:
Use MCP when the task needs remote tools exposed by an MCP server rather than locally implemented Execute handlers.
Default guidance:
sdk.CreateMCPClient(ctx, &sdk.MCPClientConfig{...})sdk.MCPTransportHTTP for streamable HTTP MCP serverssdk.MCPTransportSSE only when the server exposes legacy SSE transportTransport: ...mcpClient.Tools(ctx) and pass the result into sdk.WithTools(...)defer mcpClient.Close() after successful creationImportant behavior:
sdk.Tool values from the caller's perspectiveInputSchema into *jsonschema.Schematools/call on the remote serverTwilight AI streaming is channel-first and type-safe. Prefer type switches over loosely typed event parsing.
Important expectations:
StreamText returns *sdk.StreamResultsr.Stream must be consumed before relying on sr.Steps or sr.MessagesText() and ToResult() are the convenience paths when callers do not want manual event handlingPreserve the SDK message model and avoid backend-specific shapes leaking into public usage.
stop, length, content-filter, and tool-callsUse this structure:
ChatModel or EmbeddingModelsdk functionCheck all affected layers:
Use the built-in providers as the template. A custom provider should feel identical to existing ones from the caller's perspective.
Minimum behavior:
ChatModelDoGenerateDoStream with correct lifecycle partsWhen writing Twilight AI docs or README content:
Use these terms consistently:
WithMaxStepsStreamTextBefore finishing work in this repo, verify:
sdk APIs unless lower-level behavior is the pointStreamPart handlingWithTools(...) usage when relevant