openai

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetUsagePayloadType = "openai.getUsage.result"
)
View Source
const ResponsePayloadType = "openai.response"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey   string
	AdminKey string
	BaseURL  string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient core.HTTPContext, ctx core.IntegrationContext) (*Client, error)

func (*Client) CreateResponse

func (c *Client) CreateResponse(req CreateResponseRequest) (*OpenAIResponse, error)

func (*Client) DeleteFile added in v0.28.0

func (c *Client) DeleteFile(fileID string) error

DeleteFile removes an uploaded file. Best-effort cleanup; no-op for empty IDs.

func (*Client) GetUsage added in v0.28.0

func (c *Client) GetUsage(path string, params url.Values) ([]UsageBucket, error)

GetUsage fetches all buckets for an org Usage/Costs API path (e.g. "/organization/usage/completions"), following the next_page cursor. Requires the admin API key. Organization usage endpoints only exist on the OpenAI platform API, so requests always target the default base URL even when a custom baseURL is configured for model endpoints.

func (*Client) ListModels

func (c *Client) ListModels() ([]Model, error)

func (*Client) UploadFile added in v0.28.0

func (c *Client) UploadFile(content io.Reader, filename, purpose, contentType string) (string, error)

UploadFile uploads a file to the OpenAI Files API with the given purpose ("vision" for images, "user_data" for documents) and returns its file id.

func (*Client) Verify

func (c *Client) Verify() error

func (*Client) VerifyAdmin added in v0.28.0

func (c *Client) VerifyAdmin() error

VerifyAdmin checks the admin API key by requesting a single usage bucket.

type Configuration

type Configuration struct {
	APIKey   string `json:"apiKey"`
	AdminKey string `json:"adminKey"`
	BaseURL  string `json:"baseURL"`
}

type CreateResponse

type CreateResponse struct{}

func (*CreateResponse) Cancel

func (c *CreateResponse) Cancel(ctx core.ExecutionContext) error

func (*CreateResponse) Cleanup added in v0.7.0

func (c *CreateResponse) Cleanup(ctx core.SetupContext) error

func (*CreateResponse) Color

func (c *CreateResponse) Color() string

func (*CreateResponse) Configuration

func (c *CreateResponse) Configuration() []configuration.Field

func (*CreateResponse) Description

func (c *CreateResponse) Description() string

func (*CreateResponse) Documentation

func (c *CreateResponse) Documentation() string

func (*CreateResponse) ExampleOutput

func (c *CreateResponse) ExampleOutput() map[string]any

func (*CreateResponse) Execute

func (c *CreateResponse) Execute(ctx core.ExecutionContext) error

func (*CreateResponse) HandleHook added in v0.18.0

func (c *CreateResponse) HandleHook(ctx core.ActionHookContext) error

func (*CreateResponse) HandleWebhook

func (*CreateResponse) Hooks added in v0.18.0

func (c *CreateResponse) Hooks() []core.Hook

func (*CreateResponse) Icon

func (c *CreateResponse) Icon() string

func (*CreateResponse) Label

func (c *CreateResponse) Label() string

func (*CreateResponse) Name

func (c *CreateResponse) Name() string

func (*CreateResponse) OutputChannels

func (c *CreateResponse) OutputChannels(configuration any) []core.OutputChannel

func (*CreateResponse) ProcessQueueItem

func (c *CreateResponse) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*CreateResponse) Setup

func (c *CreateResponse) Setup(ctx core.SetupContext) error

type CreateResponseRequest

type CreateResponseRequest struct {
	Model string              `json:"model"`
	Input any                 `json:"input"`
	Text  *ResponseTextConfig `json:"text,omitempty"`
}

CreateResponseRequest is the Responses API request. Input is a plain string for text-only prompts, or []InputMessage when attaching files/images.

type CreateResponseSpec

type CreateResponseSpec struct {
	Model        string   `json:"model"`
	Input        string   `json:"input"`
	Files        []string `json:"files"`
	OutputSchema string   `json:"outputSchema"`
}

type GetUsage added in v0.28.0

type GetUsage struct{}

func (*GetUsage) Cancel added in v0.28.0

func (c *GetUsage) Cancel(ctx core.ExecutionContext) error

func (*GetUsage) Cleanup added in v0.28.0

func (c *GetUsage) Cleanup(ctx core.SetupContext) error

func (*GetUsage) Color added in v0.28.0

func (c *GetUsage) Color() string

func (*GetUsage) Configuration added in v0.28.0

func (c *GetUsage) Configuration() []configuration.Field

func (*GetUsage) Description added in v0.28.0

func (c *GetUsage) Description() string

func (*GetUsage) Documentation added in v0.28.0

func (c *GetUsage) Documentation() string

func (*GetUsage) ExampleOutput added in v0.28.0

func (c *GetUsage) ExampleOutput() map[string]any

func (*GetUsage) Execute added in v0.28.0

func (c *GetUsage) Execute(ctx core.ExecutionContext) error

func (*GetUsage) HandleHook added in v0.28.0

func (c *GetUsage) HandleHook(ctx core.ActionHookContext) error

func (*GetUsage) HandleWebhook added in v0.28.0

func (*GetUsage) Hooks added in v0.28.0

func (c *GetUsage) Hooks() []core.Hook

func (*GetUsage) Icon added in v0.28.0

func (c *GetUsage) Icon() string

func (*GetUsage) Label added in v0.28.0

func (c *GetUsage) Label() string

func (*GetUsage) Name added in v0.28.0

func (c *GetUsage) Name() string

func (*GetUsage) OutputChannels added in v0.28.0

func (c *GetUsage) OutputChannels(config any) []core.OutputChannel

func (*GetUsage) ProcessQueueItem added in v0.28.0

func (c *GetUsage) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*GetUsage) Setup added in v0.28.0

func (c *GetUsage) Setup(ctx core.SetupContext) error

type GetUsageOutput added in v0.28.0

type GetUsageOutput struct {
	Data      []map[string]any `json:"data"`
	Period    map[string]any   `json:"period"`
	UsageType string           `json:"usageType"`
}

type GetUsageSpec added in v0.28.0

type GetUsageSpec struct {
	StartDate string `json:"startDate" mapstructure:"startDate"`
	EndDate   string `json:"endDate" mapstructure:"endDate"`
	UsageType string `json:"usageType" mapstructure:"usageType"`
	GroupBy   string `json:"groupBy" mapstructure:"groupBy"`
}

type InputMessage added in v0.28.0

type InputMessage struct {
	Role    string      `json:"role"`
	Content []InputPart `json:"content"`
}

InputMessage is a role + content-parts entry in the Responses API input array.

type InputPart added in v0.28.0

type InputPart struct {
	Type   string `json:"type"`
	Text   string `json:"text,omitempty"`
	FileID string `json:"file_id,omitempty"`
}

InputPart is a content part: input_text, input_image, or input_file.

type Model

type Model struct {
	ID string `json:"id"`
}

type ModelsResponse

type ModelsResponse struct {
	Data []Model `json:"data"`
}

type OpenAI

type OpenAI struct{}

func (*OpenAI) Actions added in v0.6.0

func (o *OpenAI) Actions() []core.Action

func (*OpenAI) Cleanup added in v0.6.0

func (o *OpenAI) Cleanup(ctx core.IntegrationCleanupContext) error

func (*OpenAI) Configuration

func (o *OpenAI) Configuration() []configuration.Field

func (*OpenAI) Description

func (o *OpenAI) Description() string

func (*OpenAI) HandleHook added in v0.18.0

func (o *OpenAI) HandleHook(ctx core.IntegrationHookContext) error

func (*OpenAI) HandleRequest

func (o *OpenAI) HandleRequest(ctx core.HTTPRequestContext)

func (*OpenAI) Hooks added in v0.18.0

func (o *OpenAI) Hooks() []core.Hook

func (*OpenAI) Icon

func (o *OpenAI) Icon() string

func (*OpenAI) Instructions

func (o *OpenAI) Instructions() string

func (*OpenAI) Label

func (o *OpenAI) Label() string

func (*OpenAI) ListResources

func (o *OpenAI) ListResources(resourceType string, ctx core.ListResourcesContext) ([]core.IntegrationResource, error)

func (*OpenAI) Name

func (o *OpenAI) Name() string

func (*OpenAI) Sync

func (o *OpenAI) Sync(ctx core.SyncContext) error

func (*OpenAI) Triggers

func (o *OpenAI) Triggers() []core.Trigger

type OpenAIResponse

type OpenAIResponse struct {
	ID         string           `json:"id"`
	Model      string           `json:"model"`
	OutputText string           `json:"output_text"`
	Output     []ResponseOutput `json:"output"`
	Usage      *ResponseUsage   `json:"usage,omitempty"`
}

type ResponseContent

type ResponseContent struct {
	Type    string `json:"type"`
	Text    string `json:"text"`
	Refusal string `json:"refusal,omitempty"`
}

type ResponseFormat added in v0.28.0

type ResponseFormat struct {
	Type   string `json:"type"`             // "json_schema"
	Name   string `json:"name"`             // required by the Responses API
	Schema any    `json:"schema"`           // the JSON Schema object
	Strict bool   `json:"strict,omitempty"` // enforce exact schema conformance
}

ResponseFormat constrains the response to a JSON schema (Responses API: text.format).

type ResponseNodeMetadata added in v0.28.0

type ResponseNodeMetadata struct {
	Model            string `json:"model" mapstructure:"model"`
	StructuredOutput bool   `json:"structuredOutput" mapstructure:"structuredOutput"`
}

ResponseNodeMetadata is node-level metadata surfaced in the UI so the configured model and options are visible on the node without opening it.

type ResponseOutput

type ResponseOutput struct {
	Type    string            `json:"type"`
	Role    string            `json:"role"`
	Content []ResponseContent `json:"content"`
}

type ResponsePayload

type ResponsePayload struct {
	ID       string          `json:"id"`
	Model    string          `json:"model"`
	Text     string          `json:"text"`
	Parsed   any             `json:"parsed,omitempty"`
	Usage    *ResponseUsage  `json:"usage,omitempty"`
	Response *OpenAIResponse `json:"response"`
}

type ResponseTextConfig added in v0.28.0

type ResponseTextConfig struct {
	Format *ResponseFormat `json:"format,omitempty"`
}

ResponseTextConfig carries the structured-output format for the Responses API.

type ResponseUsage

type ResponseUsage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

type UsageBucket added in v0.28.0

type UsageBucket struct {
	Object    string           `json:"object"`
	StartTime int64            `json:"start_time"`
	EndTime   int64            `json:"end_time"`
	Results   []map[string]any `json:"results"`
}

UsageBucket is a time bucket of usage results. Results are kept generic because each usage category returns different metric fields.

type UsagePage added in v0.28.0

type UsagePage struct {
	Object   string        `json:"object"`
	Data     []UsageBucket `json:"data"`
	HasMore  bool          `json:"has_more"`
	NextPage string        `json:"next_page"`
}

UsagePage is one page of the org Usage/Costs API: buckets plus a pagination cursor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL