Skip to content

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec

Notifications You must be signed in to change notification settings

eiixy/openai-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openai

The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 2.1.0
  • Package version: 1.0.0
  • Generator version: 7.6.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://help.openai.com/

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openai "github.com/eiixy/openai-gen"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openai.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openai.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openai.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openai.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openai.ContextOperationServerIndices and openai.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openai.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openai.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.openai.com/v1

Class Method HTTP request Description
AssistantsAPI CancelRun Post /threads/{thread_id}/runs/{run_id}/cancel Cancels a run that is `in_progress`.
AssistantsAPI CreateAssistant Post /assistants Create an assistant with a model and instructions.
AssistantsAPI CreateMessage Post /threads/{thread_id}/messages Create a message.
AssistantsAPI CreateRun Post /threads/{thread_id}/runs Create a run.
AssistantsAPI CreateThread Post /threads Create a thread.
AssistantsAPI CreateThreadAndRun Post /threads/runs Create a thread and run it in one request.
AssistantsAPI DeleteAssistant Delete /assistants/{assistant_id} Delete an assistant.
AssistantsAPI DeleteMessage Delete /threads/{thread_id}/messages/{message_id} Deletes a message.
AssistantsAPI DeleteThread Delete /threads/{thread_id} Delete a thread.
AssistantsAPI GetAssistant Get /assistants/{assistant_id} Retrieves an assistant.
AssistantsAPI GetMessage Get /threads/{thread_id}/messages/{message_id} Retrieve a message.
AssistantsAPI GetRun Get /threads/{thread_id}/runs/{run_id} Retrieves a run.
AssistantsAPI GetRunStep Get /threads/{thread_id}/runs/{run_id}/steps/{step_id} Retrieves a run step.
AssistantsAPI GetThread Get /threads/{thread_id} Retrieves a thread.
AssistantsAPI ListAssistants Get /assistants Returns a list of assistants.
AssistantsAPI ListMessages Get /threads/{thread_id}/messages Returns a list of messages for a given thread.
AssistantsAPI ListRunSteps Get /threads/{thread_id}/runs/{run_id}/steps Returns a list of run steps belonging to a run.
AssistantsAPI ListRuns Get /threads/{thread_id}/runs Returns a list of runs belonging to a thread.
AssistantsAPI ModifyAssistant Post /assistants/{assistant_id} Modifies an assistant.
AssistantsAPI ModifyMessage Post /threads/{thread_id}/messages/{message_id} Modifies a message.
AssistantsAPI ModifyRun Post /threads/{thread_id}/runs/{run_id} Modifies a run.
AssistantsAPI ModifyThread Post /threads/{thread_id} Modifies a thread.
AssistantsAPI SubmitToolOuputsToRun Post /threads/{thread_id}/runs/{run_id}/submit_tool_outputs When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
AudioAPI CreateSpeech Post /audio/speech Generates audio from the input text.
AudioAPI CreateTranscription Post /audio/transcriptions Transcribes audio into the input language.
AudioAPI CreateTranslation Post /audio/translations Translates audio into English.
BatchAPI CancelBatch Post /batches/{batch_id}/cancel Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.
BatchAPI CreateBatch Post /batches Creates and executes a batch from an uploaded file of requests
BatchAPI ListBatches Get /batches List your organization's batches.
BatchAPI RetrieveBatch Get /batches/{batch_id} Retrieves a batch.
ChatAPI CreateChatCompletion Post /chat/completions Creates a model response for the given chat conversation.
CompletionsAPI CreateCompletion Post /completions Creates a completion for the provided prompt and parameters.
EmbeddingsAPI CreateEmbedding Post /embeddings Creates an embedding vector representing the input text.
FilesAPI CreateFile Post /files Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details. The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning chat or completions models. The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required format. Please contact us if you need to increase these storage limits.
FilesAPI DeleteFile Delete /files/{file_id} Delete a file.
FilesAPI DownloadFile Get /files/{file_id}/content Returns the contents of the specified file.
FilesAPI ListFiles Get /files Returns a list of files that belong to the user's organization.
FilesAPI RetrieveFile Get /files/{file_id} Returns information about a specific file.
FineTuningAPI CancelFineTuningJob Post /fine_tuning/jobs/{fine_tuning_job_id}/cancel Immediately cancel a fine-tune job.
FineTuningAPI CreateFineTuningJob Post /fine_tuning/jobs Creates a fine-tuning job which begins the process of creating a new model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. Learn more about fine-tuning
FineTuningAPI ListFineTuningEvents Get /fine_tuning/jobs/{fine_tuning_job_id}/events Get status updates for a fine-tuning job.
FineTuningAPI ListFineTuningJobCheckpoints Get /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints List checkpoints for a fine-tuning job.
FineTuningAPI ListPaginatedFineTuningJobs Get /fine_tuning/jobs List your organization's fine-tuning jobs
FineTuningAPI RetrieveFineTuningJob Get /fine_tuning/jobs/{fine_tuning_job_id} Get info about a fine-tuning job. Learn more about fine-tuning
ImagesAPI CreateImage Post /images/generations Creates an image given a prompt.
ImagesAPI CreateImageEdit Post /images/edits Creates an edited or extended image given an original image and a prompt.
ImagesAPI CreateImageVariation Post /images/variations Creates a variation of a given image.
ModelsAPI DeleteModel Delete /models/{model} Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.
ModelsAPI ListModels Get /models Lists the currently available models, and provides basic information about each one such as the owner and availability.
ModelsAPI RetrieveModel Get /models/{model} Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
ModerationsAPI CreateModeration Post /moderations Classifies if text is potentially harmful.
VectorStoresAPI CancelVectorStoreFileBatch Post /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.
VectorStoresAPI CreateVectorStore Post /vector_stores Create a vector store.
VectorStoresAPI CreateVectorStoreFile Post /vector_stores/{vector_store_id}/files Create a vector store file by attaching a File to a vector store.
VectorStoresAPI CreateVectorStoreFileBatch Post /vector_stores/{vector_store_id}/file_batches Create a vector store file batch.
VectorStoresAPI DeleteVectorStore Delete /vector_stores/{vector_store_id} Delete a vector store.
VectorStoresAPI DeleteVectorStoreFile Delete /vector_stores/{vector_store_id}/files/{file_id} Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the delete file endpoint.
VectorStoresAPI GetVectorStore Get /vector_stores/{vector_store_id} Retrieves a vector store.
VectorStoresAPI GetVectorStoreFile Get /vector_stores/{vector_store_id}/files/{file_id} Retrieves a vector store file.
VectorStoresAPI GetVectorStoreFileBatch Get /vector_stores/{vector_store_id}/file_batches/{batch_id} Retrieves a vector store file batch.
VectorStoresAPI ListFilesInVectorStoreBatch Get /vector_stores/{vector_store_id}/file_batches/{batch_id}/files Returns a list of vector store files in a batch.
VectorStoresAPI ListVectorStoreFiles Get /vector_stores/{vector_store_id}/files Returns a list of vector store files.
VectorStoresAPI ListVectorStores Get /vector_stores Returns a list of vector stores.
VectorStoresAPI ModifyVectorStore Post /vector_stores/{vector_store_id} Modifies a vector store.

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

ApiKeyAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openai.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

About

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published