Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom api host #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions OpenAI_API/OpenAIAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ public static OpenAIAPI ForAzure(string YourResourceName, string deploymentId, A
return api;
}

/// <summary>
/// Instantiate an API version for connecting to a custom OpenAI endpoint instead of the main OpenAI endpoint.
/// </summary>
/// <param name="host">Custom host</param>
/// <param name="apiKey">The API authentication information to use for API calls, or <see langword="null"/> to attempt to use the <see cref="APIAuthentication.Default"/>, potentially loading from environment vars or from a config file. Currently this library only supports the api-key flow, not the AD-Flow.</param>
/// <returns></returns>
public static OpenAIAPI ForCustomHost(string host, APIAuthentication apiKey = null) {
OpenAIAPI api = new OpenAIAPI(apiKey) {
ApiUrlFormat = $"https://{host}/" + "{0}/{1}"
};

return api;
}

/// <summary>
/// Text generation is the core function of the API. You give the API a prompt, and it generates a completion. The way you “program” the API to do a task is by simply describing the task in plain english or providing a few written examples. This simple approach works for a wide range of use cases, including summarization, translation, grammar correction, question answering, chatbots, composing emails, and much more (see the prompt library for inspiration).
/// </summary>
Expand Down