Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .claude/skills/tryagi-openai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dnx tryAGI.OpenAI.CLI <group> --help
| `user-organization-role-assignment` | 4 | |
| `vault` | 10 | |
| `vector-store` | 16 | |
| `default` | 42 | |
| `default` | 43 | |

## References

Expand Down
1 change: 1 addition & 0 deletions .claude/skills/tryagi-openai/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ Use Uploads to upload large files in multiple parts.
| `list-webhook-endpoints` | `GET /webhook_endpoints` | List Webhook Endpoints |
| `list-webhook-event-types` | `GET /webhook_event_types` | List Webhook Event Types |
| `listexternalstorageconfigurations` | `GET /organization/external_storage` | List external storage configurations |
| `organization-decisionsusage` | `GET /organization/usage/decisions` | Decisions |
| `retrieve-container` | `GET /containers/{container_id}` | Retrieve container |
| `retrieve-container-file` | `GET /containers/{container_id}/files/{file_id}` | Retrieve container file |
| `retrieve-container-file-content` | `GET /containers/{container_id}/files/{file_id}/content` | Retrieve container file content |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static Command Create()
command.Subcommands.Add(ListWebhookEndpointsCommandApiCommand.Create());
command.Subcommands.Add(ListWebhookEventTypesCommandApiCommand.Create());
command.Subcommands.Add(ListexternalstorageconfigurationsCommandApiCommand.Create());
command.Subcommands.Add(OrganizationDecisionsusageCommandApiCommand.Create());
command.Subcommands.Add(RetrieveContainerCommandApiCommand.Create());
command.Subcommands.Add(RetrieveContainerFileCommandApiCommand.Create());
command.Subcommands.Add(RetrieveContainerFileContentCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class OrganizationDecisionsusageCommandApiCommand
{
private static Option<int> StartTime { get; } = new(
name: @"--start-time")
{
Description = @"Start time (Unix seconds) of the query time range, inclusive.",
Required = true,
};

private static Option<int?> EndTime { get; } = new(
name: @"--end-time")
{
Description = @"End time (Unix seconds) of the query time range, exclusive.",
};

private static Option<global::tryAGI.OpenAI.DecisionsUsageBucketWidth?> BucketWidth { get; } = new(
name: @"--bucket-width")
{
Description = @"Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.",
};

private static Option<int?> Limit { get; } = new(
name: @"--limit")
{
Description = @"Specifies the number of buckets to return.
- `bucket_width=1d`: default: 7, max: 31
- `bucket_width=1h`: default: 24, max: 168
- `bucket_width=1m`: default: 60, max: 1440",
};

private static Option<string?> Page { get; } = new(
name: @"--page")
{
Description = @"A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.",
};

private static Option<global::System.Collections.Generic.IList<string>?> ProjectIds { get; } = new(
name: @"--project-ids")
{
Description = @"Return only usage for these projects.",
};

private static Option<global::System.Collections.Generic.IList<global::tryAGI.OpenAI.DecisionsUsageGroupBy>?> GroupBy { get; } = new(
name: @"--group-by")
{
Description = @"Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model`, `batch`, `service_tier`, `api_source` or any combination of them. When grouped by `api_source`, results use `agents_api` for attributed Agents API activity and `unlabeled` for all other activity. Without source grouping, `api_source` is null.",
};

private static Option<global::System.Collections.Generic.IList<string>?> UserIds { get; } = new(
name: @"--user-ids")
{
Description = @"Return only usage for these users.",
};

private static Option<global::System.Collections.Generic.IList<string>?> ApiKeyIds { get; } = new(
name: @"--api-key-ids")
{
Description = @"Return only usage for these API keys.",
};

private static Option<global::System.Collections.Generic.IList<string>?> Models { get; } = new(
name: @"--models")
{
Description = @"Return only usage for these models.",
};

private static Option<bool?> Batch { get; } = CliRuntime.CreateNullableBoolOption(
name: @"--batch",
description: @"If `true`, return batch jobs only. If `false`, return non-batch jobs only. By default, return both.");

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.PublicDecisionsUsageResponseResource value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}

var hints = new Dictionary<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::tryAGI.OpenAI.PublicDecisionsUsageResponseResource value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"organization-decisionsusage", @"Decisions
Get Decisions API usage details for the organization.");
command.Options.Add(StartTime);
command.Options.Add(EndTime);
command.Options.Add(BucketWidth);
command.Options.Add(Limit);
command.Options.Add(Page);
command.Options.Add(ProjectIds);
command.Options.Add(GroupBy);
command.Options.Add(UserIds);
command.Options.Add(ApiKeyIds);
command.Options.Add(Models);
command.Options.Add(Batch);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var startTime = parseResult.GetRequiredValue(StartTime);
var endTime = parseResult.GetValue(EndTime);
var bucketWidth = parseResult.GetValue(BucketWidth);
var limit = parseResult.GetValue(Limit);
var page = parseResult.GetValue(Page);
var projectIds = parseResult.GetValue(ProjectIds);
var groupBy = parseResult.GetValue(GroupBy);
var userIds = parseResult.GetValue(UserIds);
var apiKeyIds = parseResult.GetValue(ApiKeyIds);
var models = parseResult.GetValue(Models);
var batch = parseResult.GetValue(Batch);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.OrganizationDecisionsusageAsync(
startTime: startTime,
endTime: endTime,
bucketWidth: bucketWidth,
limit: limit,
page: page,
projectIds: projectIds,
groupBy: groupBy,
userIds: userIds,
apiKeyIds: apiKeyIds,
models: models,
batch: batch,
cancellationToken: cancellationToken).ConfigureAwait(false);


if (!await CliRuntime.TryWriteOutputDirectoryAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
@"Data",
cancellationToken).ConfigureAwait(false))
{
await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#nullable enable

namespace tryAGI.OpenAI
{
public partial interface IOpenAiClient
{
/// <summary>
/// Decisions<br/>
/// Get Decisions API usage details for the organization.
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="bucketWidth"></param>
/// <param name="limit"></param>
/// <param name="page"></param>
/// <param name="projectIds"></param>
/// <param name="groupBy"></param>
/// <param name="userIds"></param>
/// <param name="apiKeyIds"></param>
/// <param name="models"></param>
/// <param name="batch"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.PublicDecisionsUsageResponseResource> OrganizationDecisionsusageAsync(
int startTime,
int? endTime = default,
global::tryAGI.OpenAI.DecisionsUsageBucketWidth? bucketWidth = default,
int? limit = default,
string? page = default,
global::System.Collections.Generic.IList<string>? projectIds = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.DecisionsUsageGroupBy>? groupBy = default,
global::System.Collections.Generic.IList<string>? userIds = default,
global::System.Collections.Generic.IList<string>? apiKeyIds = default,
global::System.Collections.Generic.IList<string>? models = default,
bool? batch = default,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Decisions<br/>
/// Get Decisions API usage details for the organization.
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="bucketWidth"></param>
/// <param name="limit"></param>
/// <param name="page"></param>
/// <param name="projectIds"></param>
/// <param name="groupBy"></param>
/// <param name="userIds"></param>
/// <param name="apiKeyIds"></param>
/// <param name="models"></param>
/// <param name="batch"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.AutoSDKHttpResponse<global::tryAGI.OpenAI.PublicDecisionsUsageResponseResource>> OrganizationDecisionsusageAsResponseAsync(
int startTime,
int? endTime = default,
global::tryAGI.OpenAI.DecisionsUsageBucketWidth? bucketWidth = default,
int? limit = default,
string? page = default,
global::System.Collections.Generic.IList<string>? projectIds = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.DecisionsUsageGroupBy>? groupBy = default,
global::System.Collections.Generic.IList<string>? userIds = default,
global::System.Collections.Generic.IList<string>? apiKeyIds = default,
global::System.Collections.Generic.IList<string>? models = default,
bool? batch = default,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Wraps OrganizationDecisionsusageAsync as an IAsyncEnumerable&lt;global::tryAGI.OpenAI.DecisionsUsageBucket&gt; that auto-pages over the response.
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="bucketWidth"></param>
/// <param name="limit"></param>
/// <param name="projectIds"></param>
/// <param name="groupBy"></param>
/// <param name="userIds"></param>
/// <param name="apiKeyIds"></param>
/// <param name="models"></param>
/// <param name="batch"></param>
/// <param name="page">Initial cursor to start enumerating from. Defaults to null (first page).</param>
/// <param name="cancellationToken"></param>
global::System.Collections.Generic.IAsyncEnumerable<global::tryAGI.OpenAI.DecisionsUsageBucket> OrganizationDecisionsusageAutoPagingAsync(
int startTime, int? endTime = default,
global::tryAGI.OpenAI.DecisionsUsageBucketWidth? bucketWidth = default,
int? limit = default,
global::System.Collections.Generic.IList<string>? projectIds = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.DecisionsUsageGroupBy>? groupBy = default,
global::System.Collections.Generic.IList<string>? userIds = default,
global::System.Collections.Generic.IList<string>? apiKeyIds = default,
global::System.Collections.Generic.IList<string>? models = default,
bool? batch = default,
string? page = null,
global::System.Threading.CancellationToken cancellationToken = default);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace tryAGI.OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class DecisionsUsageApiSourceJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::tryAGI.OpenAI.DecisionsUsageApiSource>
{
/// <inheritdoc />
public override global::tryAGI.OpenAI.DecisionsUsageApiSource Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::tryAGI.OpenAI.DecisionsUsageApiSourceExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::tryAGI.OpenAI.DecisionsUsageApiSource)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::tryAGI.OpenAI.DecisionsUsageApiSource);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::tryAGI.OpenAI.DecisionsUsageApiSource value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::tryAGI.OpenAI.DecisionsUsageApiSourceExtensions.ToValueString(value));
}
}
}
Loading
Loading