Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit db5f09d

Browse files
authored
Update README.md
1 parent 12d766f commit db5f09d

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,92 @@
11
# OpenAI
2+
This is an unofficial C# library for the OpenAI API. As there are no official libraries available, we have created our own to help C# developers interact with the API easily.
23

34
[![.NET](https://github.com/managedcode/OpenAI/actions/workflows/dotnet.yml/badge.svg)](https://github.com/managedcode/OpenAI/actions/workflows/dotnet.yml)
45
[![Coverage Status](https://coveralls.io/repos/github/managedcode/OpenAI/badge.svg?branch=main&service=github)](https://coveralls.io/github/managedcode/OpenAI?branch=main)
56
[![nuget](https://github.com/managedcode/OpenAI/actions/workflows/nuget.yml/badge.svg?branch=main)](https://github.com/managedcode/Communication/actions/workflows/nuget.yml)
67
[![CodeQL](https://github.com/managedcode/OpenAI/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/managedcode/OpenAI/actions/workflows/codeql-analysis.yml)
78
[![NuGet Package](https://img.shields.io/nuget/v/ManagedCode.OpenAI.svg)](https://www.nuget.org/packages/ManagedCode.OpenAI)
89

10+
11+
12+
## Installation
13+
14+
TBD (Add installation instructions here)
15+
16+
## Usage
17+
18+
Initializing the client
19+
You can initialize the client in two ways:
20+
``` cs
21+
var client1 = GptClient.Builder("#API_KEY#")
22+
.WithOrganization("#ORGANIZATION#")
23+
.Build();
24+
```
25+
26+
```cs
27+
var client2 = GptClient.Builder("#API_KEY#")
28+
.WithOrganization("#ORGANIZATION#")
29+
.Configure(x => x.SetDefaultModel(GptModel.Ada))
30+
.Build();
31+
```
32+
33+
## Generating an image URL
34+
```cs
35+
var client = new GptClient("#API_KEY#");
36+
var img = await client.ImageClient
37+
.GenerateImage("Big man")
38+
.AsUrl().ExecuteAsync();
39+
```
40+
```cs
41+
var url = img.Content;
42+
Console.WriteLine(url);
43+
Generating an image URL with editing
44+
csharp
45+
Copy code
46+
var client = new GptClient("#API_KEY#");
47+
var imgBytes = new byte[] { };
48+
var maskBase64 = "#CONTENT#";
49+
50+
var img = await client.ImageClient
51+
.EditImage("Change color to red", x => x.FromBytes(imgBytes))
52+
.SetImageMask(x => x.FromBase64(maskBase64))
53+
.AsUrl().ExecuteAsync();
54+
```
55+
56+
```cs
57+
// Edited img URL
58+
Console.WriteLine(img.Content);
59+
Editing an image using a mask
60+
csharp
61+
Copy code
62+
var client = new GptClient("#API_KEY#");
63+
var imgBytes = new byte[] { };
64+
var imgCollection = await client.ImageClient
65+
.VariationImage(x => x.FromBytes(imgBytes))
66+
.AsBase64String()
67+
.ExecuteMultipleAsync(5);
68+
69+
foreach (var imageBase64 in imgCollection.Content)
70+
Console.WriteLine(imageBase64);
71+
```
72+
## Generating multiple image variations as base64 strings
73+
Create multiple variations of an image in base64 string format with 5 results:
74+
75+
```cs
76+
var client = new GptClient("#API_KEY#");
77+
var imgBytes = new byte[] { };
78+
var imgCollection = await client.ImageClient
79+
.VariationImage(x => x.FromBytes(imgBytes))
80+
.AsBase64String()
81+
.ExecuteMultipleAsync(5);
82+
83+
foreach (var imageBase64 in imgCollection.Content)
84+
Console.WriteLine(imageBase64);
85+
```
86+
87+
## Contributing
88+
We welcome contributions to this project. Please submit a pull request or create an issue if you'd like to help improve this library.
89+
90+
License
91+
92+
TBD (Add license information here)

0 commit comments

Comments
 (0)