Home / Market / go-writer-ai

go-writer-ai

Unofficial Go client for the Writer (writer.com) API, generated from Writer's OpenAPI spec. `writer.NewClientWithResponses("https://api.writer.com", auth)` from `github.com/psyb0t/go-writer-ai` gives typed methods for chat (`ChatWithResponse`), text completions (`CompletionsWithResponse`), models (`ModelsWithResponse`), files (`GatewayGetFilesWithResponse`, `GatewayUploadFileWithBodyWithResponse`), Knowledge Graphs (`CreateGraphWithResponse`, `QuestionWithResponse`), no-code applications (`Gener

skill★ 00 dlclawhubMIT-0Install in CosmosUpstream Source

Documentation & Preview

go-writer-ai: setup and reference

Requirements

Install

go get github.com/psyb0t/go-writer-ai

The package name is writer:

import "github.com/psyb0t/go-writer-ai"

Client

Operations

| Area | Methods | |---|---| | Chat and text | ChatWithResponse, CompletionsWithResponse | | Models | ModelsWithResponse | | Files | GatewayGetFilesWithResponse, GatewayGetFileWithResponse, GatewayUploadFileWithBodyWithResponse, GatewayDownloadFileWithResponse, GatewayDeleteFileWithResponse, GatewayRetryFailedFilesWithResponse | | Knowledge Graphs | FindGraphsWithFileStatusWithResponse, CreateGraphWithResponse, FindGraphWithFileStatusWithResponse, UpdateGraphWithResponse, DeleteGraphWithResponse, AddFileToGraphWithResponse, RemoveFileFromGraphWithResponse, QuestionWithResponse | | No-code applications | GetV1ApplicationsWithResponse, GetV1ApplicationsApplicationIdWithResponse, GenerateContentWithResponse, GetV1ApplicationsApplicationIdJobsWithResponse, PostV1ApplicationsApplicationIdJobsWithResponse, GetV1ApplicationsJobsJobIdWithResponse, PostV1ApplicationsJobsJobIdRetryWithResponse, GetV1ApplicationsApplicationIdGraphsWithResponse, PutV1ApplicationsApplicationIdGraphsWithResponse | | Tools | PostV1ToolsPdfParserFileIdWithResponse, PostV1ToolsWebSearchWithResponse, PostV1VisionWithResponse |

Each has a variant without WithResponse that returns the raw *http.Response, and most have a WithBody variant that takes any io.Reader. Graph and application IDs are openapi_types.UUID in some methods and string in others, as the spec declares them.

Uploading a file

GatewayUploadFileWithBodyWithResponse(ctx, params, contentType, body) sends the reader as the raw request body. Set contentType to the file's MIME type and fill writer.GatewayUploadFileParams (it carries the Content-Disposition header with the file name).

Streaming

With Stream: true in a chat or completion request the API answers with text/event-stream. Call client.Chat(ctx, body) from the embedded ClientInterface and read resp.Body line by line; each data: line of a chat stream decodes into writer.ChatCompletionChunk. Close the body when done.

Errors