Url
Contents
[
Hide
]AiModel.Url property
Gets or sets a URL of the model. The default value is specific for the model.
public abstract string Url { get; set; }
Examples
Shows how to change model default url.
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
AiModel model = AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey);
// Default value "https://api.openai.com/".
model.Url = "https://my.a.com/";
Shows how to use self-hosted AI model based on OpenAiModel.
public void SelfHostedModel()
{
Document doc = new Document(MyDir + "Big document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI generative language models.
AiModel model = new CustomAiModel("my-model-24b", "https://my.a.com/").WithApiKey(apiKey);
Document translatedDoc = model.Translate(doc, Language.Russian);
translatedDoc.Save(ArtifactsDir + "AI.SelfHostedModel.docx");
}
/// <summary>
/// Custom self-hosted AI model.
/// </summary>
internal class CustomAiModel : OpenAiModel
{
internal CustomAiModel(string name, string url) : base(name)
{
mUrl = url;
}
public override string Url
{
get { return mUrl; }
}
private readonly string mUrl;
}
See Also
- class AiModel
- namespace Aspose.Words.AI
- assembly Aspose.Words