Skip to content

Commit 2b537d0

Browse files
HavenDVgithub-actions[bot]
andauthored
feat: Updated OpenAPI spec (#321)
Co-authored-by: github-actions[bot] <dependabot@bot.com>
1 parent bb2ce2f commit 2b537d0

7 files changed

Lines changed: 212 additions & 3 deletions

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IUsageClient.Costs.g.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public partial interface IUsageClient
1313
/// Default Value: 1d
1414
/// </param>
1515
/// <param name="projectIds"></param>
16+
/// <param name="apiKeyIds"></param>
1617
/// <param name="groupBy"></param>
1718
/// <param name="limit">
1819
/// Default Value: 7
@@ -26,6 +27,7 @@ public partial interface IUsageClient
2627
int? endTime = default,
2728
global::tryAGI.OpenAI.UsageCostsBucketWidth? bucketWidth = default,
2829
global::System.Collections.Generic.IList<string>? projectIds = default,
30+
global::System.Collections.Generic.IList<string>? apiKeyIds = default,
2931
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.UsageCostsGroupByItem>? groupBy = default,
3032
int? limit = default,
3133
string? page = default,

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.CostsResult.g.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public sealed partial class CostsResult
3333
[global::System.Text.Json.Serialization.JsonPropertyName("project_id")]
3434
public string? ProjectId { get; set; }
3535

36+
/// <summary>
37+
///
38+
/// </summary>
39+
[global::System.Text.Json.Serialization.JsonPropertyName("api_key_id")]
40+
public string? ApiKeyId { get; set; }
41+
3642
/// <summary>
3743
/// Additional properties that are not explicitly defined in the schema
3844
/// </summary>
@@ -48,19 +54,22 @@ public sealed partial class CostsResult
4854
/// </param>
4955
/// <param name="lineItem"></param>
5056
/// <param name="projectId"></param>
57+
/// <param name="apiKeyId"></param>
5158
#if NET7_0_OR_GREATER
5259
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
5360
#endif
5461
public CostsResult(
5562
global::tryAGI.OpenAI.CostsResultObject @object,
5663
global::tryAGI.OpenAI.CostsResultAmount? amount,
5764
string? lineItem,
58-
string? projectId)
65+
string? projectId,
66+
string? apiKeyId)
5967
{
6068
this.Object = @object;
6169
this.Amount = amount;
6270
this.LineItem = lineItem;
6371
this.ProjectId = projectId;
72+
this.ApiKeyId = apiKeyId;
6473
}
6574

6675
/// <summary>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#nullable enable
2+
3+
namespace tryAGI.OpenAI
4+
{
5+
public sealed partial class CostsResultApiKeyId
6+
{
7+
/// <summary>
8+
/// Serializes the current instance to a JSON string using the provided JsonSerializerContext.
9+
/// </summary>
10+
public string ToJson(
11+
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
12+
{
13+
return global::System.Text.Json.JsonSerializer.Serialize(
14+
this,
15+
this.GetType(),
16+
jsonSerializerContext);
17+
}
18+
19+
/// <summary>
20+
/// Serializes the current instance to a JSON string using the provided JsonSerializerOptions.
21+
/// </summary>
22+
#if NET8_0_OR_GREATER
23+
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
24+
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
25+
#endif
26+
public string ToJson(
27+
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
28+
{
29+
return global::System.Text.Json.JsonSerializer.Serialize(
30+
this,
31+
jsonSerializerOptions);
32+
}
33+
34+
/// <summary>
35+
/// Deserializes a JSON string using the provided JsonSerializerContext.
36+
/// </summary>
37+
public static global::tryAGI.OpenAI.CostsResultApiKeyId? FromJson(
38+
string json,
39+
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
40+
{
41+
return global::System.Text.Json.JsonSerializer.Deserialize(
42+
json,
43+
typeof(global::tryAGI.OpenAI.CostsResultApiKeyId),
44+
jsonSerializerContext) as global::tryAGI.OpenAI.CostsResultApiKeyId;
45+
}
46+
47+
/// <summary>
48+
/// Deserializes a JSON string using the provided JsonSerializerOptions.
49+
/// </summary>
50+
#if NET8_0_OR_GREATER
51+
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
52+
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
53+
#endif
54+
public static global::tryAGI.OpenAI.CostsResultApiKeyId? FromJson(
55+
string json,
56+
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
57+
{
58+
return global::System.Text.Json.JsonSerializer.Deserialize<global::tryAGI.OpenAI.CostsResultApiKeyId>(
59+
json,
60+
jsonSerializerOptions);
61+
}
62+
63+
/// <summary>
64+
/// Deserializes a JSON stream using the provided JsonSerializerContext.
65+
/// </summary>
66+
public static async global::System.Threading.Tasks.ValueTask<global::tryAGI.OpenAI.CostsResultApiKeyId?> FromJsonStreamAsync(
67+
global::System.IO.Stream jsonStream,
68+
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
69+
{
70+
return (await global::System.Text.Json.JsonSerializer.DeserializeAsync(
71+
jsonStream,
72+
typeof(global::tryAGI.OpenAI.CostsResultApiKeyId),
73+
jsonSerializerContext).ConfigureAwait(false)) as global::tryAGI.OpenAI.CostsResultApiKeyId;
74+
}
75+
76+
/// <summary>
77+
/// Deserializes a JSON stream using the provided JsonSerializerOptions.
78+
/// </summary>
79+
#if NET8_0_OR_GREATER
80+
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
81+
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
82+
#endif
83+
public static global::System.Threading.Tasks.ValueTask<global::tryAGI.OpenAI.CostsResultApiKeyId?> FromJsonStreamAsync(
84+
global::System.IO.Stream jsonStream,
85+
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
86+
{
87+
return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::tryAGI.OpenAI.CostsResultApiKeyId?>(
88+
jsonStream,
89+
jsonSerializerOptions);
90+
}
91+
}
92+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#nullable enable
3+
4+
namespace tryAGI.OpenAI
5+
{
6+
/// <summary>
7+
///
8+
/// </summary>
9+
public sealed partial class CostsResultApiKeyId
10+
{
11+
12+
/// <summary>
13+
/// Additional properties that are not explicitly defined in the schema
14+
/// </summary>
15+
[global::System.Text.Json.Serialization.JsonExtensionData]
16+
public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object>();
17+
}
18+
}

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.UsageCostsGroupByItem.g.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ namespace tryAGI.OpenAI
88
/// </summary>
99
public enum UsageCostsGroupByItem
1010
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
ApiKeyId,
1115
/// <summary>
1216
///
1317
/// </summary>
@@ -30,6 +34,7 @@ public static string ToValueString(this UsageCostsGroupByItem value)
3034
{
3135
return value switch
3236
{
37+
UsageCostsGroupByItem.ApiKeyId => "api_key_id",
3338
UsageCostsGroupByItem.LineItem => "line_item",
3439
UsageCostsGroupByItem.ProjectId => "project_id",
3540
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
@@ -42,6 +47,7 @@ public static string ToValueString(this UsageCostsGroupByItem value)
4247
{
4348
return value switch
4449
{
50+
"api_key_id" => UsageCostsGroupByItem.ApiKeyId,
4551
"line_item" => UsageCostsGroupByItem.LineItem,
4652
"project_id" => UsageCostsGroupByItem.ProjectId,
4753
_ => null,

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.UsageClient.Costs.g.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ partial void PrepareCostsArguments(
3131
ref int? endTime,
3232
ref global::tryAGI.OpenAI.UsageCostsBucketWidth? bucketWidth,
3333
global::System.Collections.Generic.IList<string>? projectIds,
34+
global::System.Collections.Generic.IList<string>? apiKeyIds,
3435
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.UsageCostsGroupByItem>? groupBy,
3536
ref int? limit,
3637
ref string? page);
@@ -41,6 +42,7 @@ partial void PrepareCostsRequest(
4142
int? endTime,
4243
global::tryAGI.OpenAI.UsageCostsBucketWidth? bucketWidth,
4344
global::System.Collections.Generic.IList<string>? projectIds,
45+
global::System.Collections.Generic.IList<string>? apiKeyIds,
4446
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.UsageCostsGroupByItem>? groupBy,
4547
int? limit,
4648
string? page);
@@ -62,6 +64,7 @@ partial void ProcessCostsResponseContent(
6264
/// Default Value: 1d
6365
/// </param>
6466
/// <param name="projectIds"></param>
67+
/// <param name="apiKeyIds"></param>
6568
/// <param name="groupBy"></param>
6669
/// <param name="limit">
6770
/// Default Value: 7
@@ -75,6 +78,7 @@ partial void ProcessCostsResponseContent(
7578
int? endTime = default,
7679
global::tryAGI.OpenAI.UsageCostsBucketWidth? bucketWidth = default,
7780
global::System.Collections.Generic.IList<string>? projectIds = default,
81+
global::System.Collections.Generic.IList<string>? apiKeyIds = default,
7882
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.UsageCostsGroupByItem>? groupBy = default,
7983
int? limit = default,
8084
string? page = default,
@@ -89,6 +93,7 @@ partial void ProcessCostsResponseContent(
8993
endTime: ref endTime,
9094
bucketWidth: ref bucketWidth,
9195
projectIds: projectIds,
96+
apiKeyIds: apiKeyIds,
9297
groupBy: groupBy,
9398
limit: ref limit,
9499
page: ref page);
@@ -123,6 +128,7 @@ partial void ProcessCostsResponseContent(
123128
.AddOptionalParameter("end_time", endTime?.ToString())
124129
.AddOptionalParameter("bucket_width", bucketWidth?.ToValueString())
125130
.AddOptionalParameter("project_ids", projectIds, delimiter: ",", explode: true)
131+
.AddOptionalParameter("api_key_ids", apiKeyIds, delimiter: ",", explode: true)
126132
.AddOptionalParameter("group_by", groupBy, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
127133
.AddOptionalParameter("limit", limit?.ToString())
128134
.AddOptionalParameter("page", page)
@@ -171,6 +177,7 @@ partial void ProcessCostsResponseContent(
171177
endTime: endTime,
172178
bucketWidth: bucketWidth,
173179
projectIds: projectIds,
180+
apiKeyIds: apiKeyIds,
174181
groupBy: groupBy,
175182
limit: limit,
176183
page: page);

src/libs/tryAGI.OpenAI/openapi.yaml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14266,6 +14266,64 @@ paths:
1426614266
curl https://api.openai.com/v1/organization/audit_logs \
1426714267
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
1426814268
-H "Content-Type: application/json"
14269+
node.js: >-
14270+
import OpenAI from 'openai';
14271+
14272+
14273+
const client = new OpenAI({
14274+
adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
14275+
});
14276+
14277+
14278+
// Automatically fetches more pages as needed.
14279+
14280+
for await (const auditLogListResponse of
14281+
client.admin.organization.auditLogs.list()) {
14282+
console.log(auditLogListResponse.id);
14283+
}
14284+
python: |-
14285+
import os
14286+
from openai import OpenAI
14287+
14288+
client = OpenAI(
14289+
admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted
14290+
)
14291+
page = client.admin.organization.audit_logs.list()
14292+
page = page.data[0]
14293+
print(page.id)
14294+
go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.AuditLogs.List(context.TODO(), openai.AdminOrganizationAuditLogListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
14295+
java: >-
14296+
package com.openai.example;
14297+
14298+
14299+
import com.openai.client.OpenAIClient;
14300+
14301+
import com.openai.client.okhttp.OpenAIOkHttpClient;
14302+
14303+
import
14304+
com.openai.models.admin.organization.auditlogs.AuditLogListPage;
14305+
14306+
import
14307+
com.openai.models.admin.organization.auditlogs.AuditLogListParams;
14308+
14309+
14310+
public final class Main {
14311+
private Main() {}
14312+
14313+
public static void main(String[] args) {
14314+
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
14315+
14316+
AuditLogListPage page = client.admin().organization().auditLogs().list();
14317+
}
14318+
}
14319+
ruby: |-
14320+
require "openai"
14321+
14322+
openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")
14323+
14324+
page = openai.admin.organization.audit_logs.list
14325+
14326+
puts(page)
1426914327
response: |
1427014328
{
1427114329
"object": "list",
@@ -14788,11 +14846,19 @@ paths:
1478814846
type: array
1478914847
items:
1479014848
type: string
14849+
- name: api_key_ids
14850+
in: query
14851+
description: Return only costs for these API keys.
14852+
required: false
14853+
schema:
14854+
type: array
14855+
items:
14856+
type: string
1479114857
- name: group_by
1479214858
in: query
1479314859
description: >-
1479414860
Group the costs by the specified fields. Support fields include
14795-
`project_id`, `line_item` and any combination of them.
14861+
`project_id`, `line_item`, `api_key_id` and any combination of them.
1479614862
required: false
1479714863
schema:
1479814864
type: array
@@ -14801,6 +14867,7 @@ paths:
1480114867
enum:
1480214868
- project_id
1480314869
- line_item
14870+
- api_key_id
1480414871
- name: limit
1480514872
in: query
1480614873
description: >
@@ -14853,7 +14920,8 @@ paths:
1485314920
"currency": "usd"
1485414921
},
1485514922
"line_item": null,
14856-
"project_id": null
14923+
"project_id": null,
14924+
"api_key_id": null
1485714925
}
1485814926
]
1485914927
}
@@ -36840,6 +36908,13 @@ components:
3684036908
When `group_by=project_id`, this field provides the project ID
3684136909
of the grouped costs result.
3684236910
- type: 'null'
36911+
api_key_id:
36912+
anyOf:
36913+
- type: string
36914+
description: >-
36915+
When `group_by=api_key_id`, this field provides the API Key ID
36916+
of the grouped costs result.
36917+
- type: 'null'
3684336918
required:
3684436919
- object
3684536920
x-oaiMeta:

0 commit comments

Comments
 (0)