Skip to content

Commit

Permalink
feat: Improved pricing constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Apr 3, 2024
1 parent 7ec88ba commit 777256e
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<PropertyGroup Label="Nuget">
<Version>2.0.2</Version>
<Version>2.0.3</Version>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>tryAGI and contributors</Authors>
Expand Down
12 changes: 6 additions & 6 deletions src/libs/OpenAI.Constants/Chat/ChatModels.3.5.Turbo.Legacy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ namespace OpenAI.Constants;
public static ChatModels Gpt35Turbo_0613 { get; } = new(
Id: Gpt35Turbo_0613Id,
ContextLength: 4_096,
PricePerInputTokenInUsd: 0.0015 * 0.001,
PricePerOutputTokenInUsd: 0.0020 * 0.001);
PricePerInputTokenInUsd: 1.5 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 2.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35Turbo_0301Id"/>
[Obsolete("Marked as Legacy. Will be deprecated on June 13, 2024.")]
public static ChatModels Gpt35Turbo_0301 { get; } = new(
Id: Gpt35Turbo_0301Id,
ContextLength: 4_096,
PricePerInputTokenInUsd: 0.0020 * 0.001,
PricePerOutputTokenInUsd: 0.0020 * 0.001);
PricePerInputTokenInUsd: 2.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 2.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35Turbo_16k_0613Id"/>
[Obsolete("Marked as Legacy. Will be deprecated on June 13, 2024.")]
public static ChatModels Gpt35Turbo_16k_0613 { get; } = new(
Id: Gpt35Turbo_16k_0613Id,
ContextLength: 16_385,
PricePerInputTokenInUsd: 0.0030 * 0.001,
PricePerOutputTokenInUsd: 0.0040 * 0.001);
PricePerInputTokenInUsd: 3.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 4.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35Turbo_16kId"/>
[Obsolete("Marked as Legacy. Will be deprecated on June 13, 2024.")]
Expand Down
18 changes: 9 additions & 9 deletions src/libs/OpenAI.Constants/Chat/ChatModels.3.5.Turbo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ namespace OpenAI.Constants;
public static ChatModels Gpt35Turbo_1106 { get; } = new(
Id: Gpt35Turbo_1106Id,
ContextLength: 16_385,
PricePerInputTokenInUsd: 0.0010 * 0.001,
PricePerOutputTokenInUsd: 0.0020 * 0.001);
PricePerInputTokenInUsd: 1.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 2.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35Turbo_0125Id"/>
public static ChatModels Gpt35Turbo_0125 { get; } = new(
Id: Gpt35Turbo_0125Id,
ContextLength: 16_385,
PricePerInputTokenInUsd: 0.0005 * 0.001,
PricePerOutputTokenInUsd: 0.0015 * 0.001);
PricePerInputTokenInUsd: 0.5 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 1.5 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35TurboInstructId"/>
public static ChatModels Gpt35TurboInstruct { get; } = new(
Id: Gpt35TurboInstructId,
ContextLength: 4_096,
PricePerInputTokenInUsd: 0.0015 * 0.001,
PricePerOutputTokenInUsd: 0.0020 * 0.001);
PricePerInputTokenInUsd: 1.5 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 2.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt35TurboId"/>
public static ChatModels Gpt35Turbo { get; } = Gpt35Turbo_0125 with
{
Id = Gpt35TurboId,
FineTuningPricePerTrainingTokenInUsd = 0.0080 * 0.001,
FineTuningPricePerInputTokenInUsd = 0.0030 * 0.001,
FineTuningPricePerOutputTokenInUsd = 0.0060 * 0.001,
FineTuningPricePerTrainingTokenInUsd = 8.0 * UsdPerMillionTokens,
FineTuningPricePerInputTokenInUsd = 3.0 * UsdPerMillionTokens,
FineTuningPricePerOutputTokenInUsd = 6.0 * UsdPerMillionTokens,
};
}
4 changes: 2 additions & 2 deletions src/libs/OpenAI.Constants/Chat/ChatModels.4.32k.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace OpenAI.Constants;
public static ChatModels Gpt4_32k_0613 { get; } = new(
Id: Gpt4_32k_0613Id,
ContextLength: 32_768,
PricePerInputTokenInUsd: 0.0600 * 0.001,
PricePerOutputTokenInUsd: 0.1200 * 0.001);
PricePerInputTokenInUsd: 60.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 120.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt4_32kId"/>
public static ChatModels Gpt4_32k { get; } = Gpt4_32k_0613 with
Expand Down
8 changes: 4 additions & 4 deletions src/libs/OpenAI.Constants/Chat/ChatModels.4.Turbo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ namespace OpenAI.Constants;
public static ChatModels Gpt4_1106_Preview { get; } = new(
Id: Gpt4_1106_PreviewId,
ContextLength: 128_000,
PricePerInputTokenInUsd: 0.0100 * 0.001,
PricePerOutputTokenInUsd: 0.0300 * 0.001);
PricePerInputTokenInUsd: 10.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 30.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt4_0125_PreviewId"/>
public static ChatModels Gpt4_0125_Preview { get; } = new(
Id: Gpt4_0125_PreviewId,
ContextLength: 128_000,
PricePerInputTokenInUsd: 0.0100 * 0.001,
PricePerOutputTokenInUsd: 0.0300 * 0.001);
PricePerInputTokenInUsd: 10.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 30.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt4TurboPreviewId"/>
public static ChatModels Gpt4TurboPreview { get; } = Gpt4_0125_Preview with
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OpenAI.Constants/Chat/ChatModels.4.Vision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace OpenAI.Constants;
public static ChatModels Gpt4_1106_VisionPreview { get; } = new(
Gpt4_1106_VisionPreviewId,
ContextLength: 128_000,
PricePerInputTokenInUsd: 0.0100 * 0.001,
PricePerOutputTokenInUsd: 0.0300 * 0.001);
PricePerInputTokenInUsd: 10.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 30.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt4VisionPreviewId"/>
public static ChatModels Gpt4VisionPreview { get; } = Gpt4_1106_VisionPreview with
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OpenAI.Constants/Chat/ChatModels.4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace OpenAI.Constants;
public static ChatModels Gpt4_0613 { get; } = new(
Id: Gpt4_0613Id,
ContextLength: 8_192,
PricePerInputTokenInUsd: 0.0300 * 0.001,
PricePerOutputTokenInUsd: 0.0600 * 0.001);
PricePerInputTokenInUsd: 30.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd: 60.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Gpt4Id"/>
public static ChatModels Gpt4 { get; } = Gpt4_0613 with
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OpenAI.Constants/Embedding/EmbeddingModels.V2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace OpenAI.Constants;
public static EmbeddingModels Ada002 { get; } = new(
Id: Ada002Id,
MaxInputTokens: 8_191,
PricePerTokenInUsd: 0.00010 * 0.001);
PricePerTokenInUsd: 0.10 * UsdPerMillionTokens);
}
4 changes: 2 additions & 2 deletions src/libs/OpenAI.Constants/Embedding/EmbeddingModels.V3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace OpenAI.Constants;
public static EmbeddingModels Version3Small { get; } = new(
Id: Version3SmallId,
MaxInputTokens: 8_191,
PricePerTokenInUsd: 0.00002 * 0.001);
PricePerTokenInUsd: 0.02 * UsdPerMillionTokens);

/// <inheritdoc cref="Version3LargeId"/>
public static EmbeddingModels Version3Large { get; } = new(
Id: Version3LargeId,
MaxInputTokens: 8_191,
PricePerTokenInUsd: 0.00013 * 0.001);
PricePerTokenInUsd: 0.13 * UsdPerMillionTokens);
}
22 changes: 22 additions & 0 deletions src/libs/OpenAI.Constants/Helpers/InternalConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace OpenAI.Constants.Helpers;

/// <summary>
/// Internal constants used by the OpenAI SDK.
/// </summary>
public static class InternalConstants
{
/// <summary>
/// Just a constant for 1e-3.
/// </summary>
public const double UsdPerThousandTokens = 1e-3;

/// <summary>
/// Just a constant for 1e-6.
/// </summary>
public const double UsdPerMillionTokens = 1e-6;

/// <summary>
/// Just a constant for 1e-9.
/// </summary>
public const double UsdPerBillionTokens = 1e-9;
}
4 changes: 4 additions & 0 deletions src/libs/OpenAI.Constants/OpenAI.Constants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</Description>
<PackageTags>openai;constants;prices;pricing;gpt-3.5;gpt-4;chatgpt;vision;audio;embedding;moderation;image;chat</PackageTags>
</PropertyGroup>

<ItemGroup Label="Usings">
<Using Include="OpenAI.Constants.Helpers.InternalConstants" Static="true" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace OpenAI.Constants;
/// <inheritdoc cref="Tts1Id"/>
public static TextToSpeechModels Tts1 { get; } = new(
Id: Tts1Id,
PricePerCharacterInUsd: 0.015 * 0.001);
PricePerCharacterInUsd: 15.0 * UsdPerMillionTokens);

/// <inheritdoc cref="Tts1HdId"/>
public static TextToSpeechModels Tts1Hd { get; } = new(
Id: Tts1HdId,
PricePerCharacterInUsd: 0.030 * 0.001);
PricePerCharacterInUsd: 30.0 * UsdPerMillionTokens);
}

0 comments on commit 777256e

Please sign in to comment.