Add Gemini 4 Carbon, Gemini 4 Hydrogen and Kling 4 video models (#4616)

* Add Gemini 4 Carbon and Kling 4 video models

* Include Kling 4 models in the video driver catalog test

* Document the Kling 4 prompt limit for non-English text

Kling 4.0 and 4.0 Flash take 26,000 characters of English but 11,000
of other languages, with mixed text sharing the limit in proportion.
The video page and the quotas page said 26,000 for every prompt.

- txt2vid.md and rate-limits-and-quotas.md give both limits, the rule
  for mixed text, and the error each one returns.
- Puter still rejects only a prompt over 26,000 characters. Kling
  enforces the lower limit, and its refusal reaches the caller as
  `upstream_bad_request` with nothing charged. A test covers that path.

* Add Gemini 4 Hydrogen and cap unary Gemini 4 Carbon output

Google released `gemini-4-hydrogen` on 2026-11-12. It uses the same
native request shape as Carbon and Argon.

- Hydrogen is served natively at $1.50 input, $7.50 output and $0.075
  cached input per million tokens, with fast service at 1.8 times
  those rates. It accepts `low`, `medium`, `high` and `xhigh` reasoning
  effort, ignores temperature, and takes text and images.
- A Carbon response that isn't streamed is capped at 32,768 output
  tokens, as Argon's already is, and the credit hold is sized to that
  cap. Google reports this limit for both models. The cap is now a
  field of the native model options instead of a check on Argon's id.
- chat.md and rate-limits-and-quotas.md list Hydrogen's reasoning
  levels and limits and Carbon's unary cap.

* Move the reasoning_effort model list out of the chat options table

The `reasoning_effort` row in chat.md listed the models that read the
option. Model-specific details belong under Model-specific features,
which already gives each family's accepted values.

- The row no longer names models.
- The Gemini and Moonshot Kimi sections say that their other models
  ignore the option.

---------

Co-authored-by: Daniel Salazar <daniel.salazar@puter.com>
This commit is contained in:
Filip KujundžićandDaniel Salazar authored and GitHub committed 2026-11-14 00:23:04 -07:00
1 parent f6139147fd
commit 4ec125bbc6
11 files changed
+416 -32

No files matched your search

@@ -552,6 +552,8 @@ describe('VideoGenerationDriver.generate provider routing', () => {
'kling-3.0',
'kling-3.0-omni',
'kling-3.0-turbo',
'kling-4.0',
'kling-4.0-flash',
'kling-o1',
]);
});
@@ -113,7 +113,6 @@ describe.skipIf(skipUnlessEnv(ENV_VAR))(
expect(typeof text === 'string' && text.length > 0).toBe(true);
},
);
},
);
@@ -377,3 +376,36 @@ describe.skipIf(skipUnlessEnv(ENV_VAR))(
);
},
);
describe.skipIf(skipUnlessEnv(ENV_VAR))(
'Gemini 4 Carbon and Hydrogen (integration)',
() => {
it.each([
['gemini-4-carbon', 'low'],
['gemini-4-hydrogen', 'xhigh'],
])(
'generates a native text completion from %s at %s effort',
{ timeout: INTEGRATION_TEST_TIMEOUT_MS },
async (model, effort) => {
const provider = new GeminiChatProvider(
{ apiKey: optionalEnv(ENV_VAR)! },
makeMeteringStub(),
);
const result = await withTestActor(() =>
provider.complete({
model,
messages: [{ role: 'user', content: 'Reply with OK.' }],
reasoning_effort: effort,
max_tokens: 32768,
} as ICompleteArguments),
);
const message = result as IChatMessageResult;
expect(typeof message.message.content).toBe('string');
expect(
(message.message.content as string).trim().length,
).toBeGreaterThan(0);
expectBilledOutput(message.usage, message.usageDetails);
},
);
},
);
@@ -114,6 +114,8 @@ const makeProvider = (
const ARGON = GEMINI_MODELS.find((m) => m.id === 'gemini-4-argon')!;
const LAUNCH = new Date('2026-10-14T12:00:00Z');
const NATIVE_IDS = [
'gemini-4-hydrogen',
'gemini-4-carbon',
'gemini-4-argon',
'gemini-3.1-flash-lite',
'gemini-3-flash-preview',
@@ -1616,3 +1618,119 @@ describe('geminiNativeClient deadline', () => {
expect(isUpstreamTimeoutError(err)).toBe(false);
});
});
describe('Gemini 4 Carbon', () => {
it.each([
['2026-11-30T23:59:59.999Z', 200, 1000, 10],
['2026-12-01T00:00:00.000Z', 400, 2000, 20],
])(
'routes natively and meters thinking at %s',
async (date, input, output, cached) => {
generateContent.mockResolvedValueOnce(
textResponse('OK', { ...LIVE_USAGE, cachedContentTokenCount: 6 }),
);
await complete(
{
model: 'google/gemini-4-carbon',
temperature: 0.5,
reasoning_effort: 'medium',
},
new Date(date),
);
expect(requestOf().model).toBe('gemini-4-carbon');
expect(requestOf().config).not.toHaveProperty('temperature');
expect(openAICreate).not.toHaveBeenCalled();
expect(recordSpy.mock.calls[0]![3]).toMatchObject({
prompt_tokens: 30 * input,
completion_tokens: 5 * output,
thinking_tokens: 69 * output,
cached_tokens: 6 * cached,
});
},
);
it.each([
['no max_tokens', undefined],
['a larger max_tokens', 65_536],
])(
'caps a non-streamed request with %s at 32,768 output tokens',
async (_label, maxTokens) => {
generateContent.mockResolvedValueOnce(textResponse('OK'));
await complete({ model: 'gemini-4-carbon', max_tokens: maxTokens });
expect(requestOf().config.maxOutputTokens).toBe(32_768);
},
);
it('sends a stream the max_tokens it asked for', async () => {
generateContentStream.mockResolvedValueOnce(
asAsyncIterable([textResponse('OK')]),
);
await runStream({ model: 'gemini-4-carbon', max_tokens: 65_536 });
expect(requestOf(generateContentStream).config.maxOutputTokens).toBe(
65_536,
);
});
});
describe('Gemini 4 Hydrogen', () => {
const hydrogen = (args: Partial<ICompleteArguments>) =>
complete(
{ model: 'gemini-4-hydrogen', ...args },
new Date('2026-12-01T00:00:00.000Z'),
);
it('routes natively and meters thinking at its own rates', async () => {
generateContent.mockResolvedValueOnce(
textResponse('OK', { ...LIVE_USAGE, cachedContentTokenCount: 6 }),
);
await hydrogen({ model: 'google/gemini-4-hydrogen', temperature: 0.5 });
expect(requestOf().model).toBe('gemini-4-hydrogen');
expect(requestOf().config).not.toHaveProperty('temperature');
expect(requestOf().config).not.toHaveProperty('thinkingConfig');
expect(openAICreate).not.toHaveBeenCalled();
expect(recordSpy.mock.calls[0]![2]).toBe('gemini:gemini-4-hydrogen');
expect(recordSpy.mock.calls[0]![3]).toMatchObject({
prompt_tokens: 30 * 150,
completion_tokens: 5 * 750,
thinking_tokens: 69 * 750,
cached_tokens: 6 * 7.5,
});
});
it.each([
['low', 'LOW'],
['medium', 'MEDIUM'],
['high', 'HIGH'],
['xhigh', 'XHIGH'],
])('sends reasoning_effort %s as thinkingLevel %s', async (effort, level) => {
generateContent.mockResolvedValueOnce(textResponse('OK'));
await hydrogen({
reasoning_effort: effort as ICompleteArguments['reasoning_effort'],
});
expect(requestOf().config.thinkingConfig).toEqual({
thinkingLevel: level,
});
});
it.each(['none', 'minimal', 'max'])(
'rejects reasoning_effort %s before calling Google',
async (effort) => {
await expect(
hydrogen({
reasoning_effort:
effort as ICompleteArguments['reasoning_effort'],
}),
).rejects.toMatchObject({
statusCode: 400,
legacyCode: 'bad_request',
});
expect(generateContent).not.toHaveBeenCalled();
},
);
it('sends a non-streamed request the max_tokens it asked for', async () => {
generateContent.mockResolvedValueOnce(textResponse('OK'));
await hydrogen({ max_tokens: 65_536 });
expect(requestOf().config.maxOutputTokens).toBe(65_536);
});
});
@@ -42,22 +42,18 @@ import {
} from '../../../protocols/openaiCompatible/OpenAICompatProvider.js';
import { usesGoogleGeminiEndpoint } from '../geminiRest.js';
import { geminiNativeClient } from './geminiNative.js';
import {
GEMINI_MODELS,
GEMINI_NATIVE_MODELS,
GEMINI_ARGON_NON_STREAM_MAX_TOKENS,
} from './models.js';
import { GEMINI_MODELS, GEMINI_NATIVE_MODELS } from './models.js';
type GroundingContent = { grounding_metadata?: unknown };
/** Unary Argon uses a lower output cap than streaming. */
/** Some native models have a lower output cap when the response isn't streamed. */
const nativeOutputCap = (
args: ICompleteArguments,
model: IChatModel,
): number | undefined =>
model.id === 'gemini-4-argon' && !args.stream
? GEMINI_ARGON_NON_STREAM_MAX_TOKENS
: undefined;
args.stream
? undefined
: GEMINI_NATIVE_MODELS.get(model.id)?.unaryMaxTokens;
const COMPAT_BASE_URL =
'https://generativelanguage.googleapis.com/v1beta/openai/';
@@ -29,6 +29,8 @@ export interface GeminiNativeOptions {
reasoningEfforts: ReadonlySet<ReasoningEffort>;
/** False where Google ignores temperature, so it isn't sent. */
temperature: boolean;
/** Output cap of a response that isn't streamed, where Google's is lower. */
unaryMaxTokens?: number;
}
const FLASH_NATIVE_OPTIONS: GeminiNativeOptions = {
@@ -36,16 +38,25 @@ const FLASH_NATIVE_OPTIONS: GeminiNativeOptions = {
temperature: true,
};
// Google's model metadata reports the unary cap; streaming keeps the catalog cap.
const ARGON_CARBON_NATIVE_OPTIONS: GeminiNativeOptions = {
reasoningEfforts: new Set(['low', 'medium', 'high']),
temperature: false,
unaryMaxTokens: 32_768,
};
/**
* Served natively: the OpenAI-compatible endpoint omits these models' thinking
* count from usage.
*/
export const GEMINI_NATIVE_MODELS: ReadonlyMap<string, GeminiNativeOptions> =
new Map([
['gemini-4-argon', ARGON_CARBON_NATIVE_OPTIONS],
['gemini-4-carbon', ARGON_CARBON_NATIVE_OPTIONS],
[
'gemini-4-argon',
'gemini-4-hydrogen',
{
reasoningEfforts: new Set(['low', 'medium', 'high']),
reasoningEfforts: new Set(['low', 'medium', 'high', 'xhigh']),
temperature: false,
},
],
@@ -88,7 +99,7 @@ const FLASH_LIST_PRICING = listPricingFrom(
FLASH_LAUNCH_COSTS,
);
const ARGON_LAUNCH_COSTS: ModelCost = {
const GEMINI_4_LAUNCH_COSTS: ModelCost = {
tokens: 1_000_000,
prompt_tokens: 200,
completion_tokens: 1000,
@@ -119,9 +130,6 @@ const PRO_LONG_CONTEXT_PRICING: ModelPricingOverride[] = [
},
];
// Google's unary model metadata reports this cap; streaming keeps the catalog cap.
export const GEMINI_ARGON_NON_STREAM_MAX_TOKENS = 32_768;
export const GEMINI_MODELS: IChatModel[] = [
{
puterId: 'google:google/gemini-4-argon',
@@ -143,12 +151,66 @@ export const GEMINI_MODELS: IChatModel[] = [
input_cost_key: 'prompt_tokens',
output_cost_key: 'completion_tokens',
serviceSpeedRates: { fast: 1.8 },
costs: ARGON_LAUNCH_COSTS,
costs: GEMINI_4_LAUNCH_COSTS,
pricingOverrides: listPricingFrom(
'2026-12-01T00:00:00Z',
ARGON_LAUNCH_COSTS,
GEMINI_4_LAUNCH_COSTS,
),
},
{
puterId: 'google:google/gemini-4-carbon',
id: 'gemini-4-carbon',
// The native adapter forwards only text and image parts.
modalities: {
input: ['text', 'image'],
output: ['text'],
},
open_weights: false,
tool_call: true,
release_date: '2026-11-10',
name: 'Gemini 4 Carbon',
aliases: ['google/gemini-4-carbon'],
// One window shared by input, thinking and output.
context: 1_048_576,
max_tokens: 65_536,
costs_currency: 'usd-cents',
input_cost_key: 'prompt_tokens',
output_cost_key: 'completion_tokens',
serviceSpeedRates: { fast: 1.8 },
costs: GEMINI_4_LAUNCH_COSTS,
pricingOverrides: listPricingFrom(
'2026-12-01T00:00:00Z',
GEMINI_4_LAUNCH_COSTS,
),
},
{
puterId: 'google:google/gemini-4-hydrogen',
id: 'gemini-4-hydrogen',
// The native adapter forwards only text and image parts.
modalities: {
input: ['text', 'image'],
output: ['text'],
},
open_weights: false,
tool_call: true,
release_date: '2026-11-12',
name: 'Gemini 4 Hydrogen',
aliases: ['google/gemini-4-hydrogen'],
// One window shared by input, thinking and output.
context: 1_048_576,
max_tokens: 65_536,
costs_currency: 'usd-cents',
input_cost_key: 'prompt_tokens',
output_cost_key: 'completion_tokens',
serviceSpeedRates: { fast: 1.8 },
costs: {
tokens: 1_000_000,
prompt_tokens: 150,
completion_tokens: 750,
thinking_tokens: 750,
cached_tokens: 7.5,
},
},
{
puterId: 'google:google/gemini-3.5-flash',
id: 'gemini-3.5-flash',
@@ -39,10 +39,10 @@ const VIDEO_TIMEOUT_MS = 5 * 60 * 1000;
describe.skipIf(skipUnlessEnv(ENV_VAR))(
'KlingVideoProvider (integration)',
() => {
it(
'generates a video URL from kling-2.5-turbo',
it.each(['kling-2.5-turbo', 'kling-4.0', 'kling-4.0-flash'])(
'generates a video URL from %s',
{ timeout: VIDEO_TIMEOUT_MS },
async () => {
async (model) => {
const provider = new KlingVideoProvider(
{ apiKey: optionalEnv(ENV_VAR)! },
makeMeteringStub(),
@@ -51,7 +51,7 @@ describe.skipIf(skipUnlessEnv(ENV_VAR))(
const url = await withTestActor(() =>
provider.generate({
model: 'kling-2.5-turbo',
model,
prompt: 'a red ball rolls to the right',
resolution: '720p',
seconds: 5,
@@ -37,6 +37,7 @@ import {
type MockInstance,
} from 'vitest';
import { translateProviderError } from '../../../../../controllers/drivers/DriverController.js';
import { Context } from '../../../../../core/context.js';
import type { MeteringService } from '../../../../../services/metering/MeteringService.js';
import { PuterServer } from '../../../../../server.js';
@@ -158,10 +159,12 @@ describe('KlingVideoProvider construction and catalog', () => {
).toThrow(/API key/i);
});
it('defaults to Kling 3.0 Turbo and lists the six models', () => {
it('defaults to Kling 3.0 Turbo and lists the supported models', () => {
const provider = makeProvider();
expect(provider.getDefaultModel()).toBe('kling-3.0-turbo');
expect(provider.models().map((m) => m.id)).toEqual([
'kling-4.0',
'kling-4.0-flash',
'kling-3.0-turbo',
'kling-3.0',
'kling-3.0-omni',
@@ -744,3 +747,112 @@ describe('KlingVideoProvider after the caller leaves', () => {
expect(incrementUsageSpy).not.toHaveBeenCalled();
});
});
describe('Kling 4 generation', () => {
it.each([
['kling-4.0', 30, '1080p', 23.55],
['kling-4.0-flash', 20, '720p', 9.42],
])(
'generates and bills %s at flagship rates',
async (model, seconds, size, cents) => {
mockTaskFlow(succeededTask());
await generate({
model,
seconds,
size,
prompt: 'a'.repeat(26_000),
generate_audio: true,
});
expect(sentUrl()).toBe(
`https://api-singapore.klingai.com/text-to-video/${model}`,
);
expect(sentBody().settings).toMatchObject({
duration: seconds,
resolution: size,
});
expect(sentBody().settings).not.toHaveProperty('audio');
expect(incrementUsageSpy.mock.calls[0]![3]).toBe(
Math.round(seconds * cents * 1_000_000),
);
},
);
it('routes Flash first frames to image-to-video', async () => {
mockTaskFlow(succeededTask());
await generate({
model: 'kling-4.0-flash',
input_reference: 'https://example.com/frame.png',
});
expect(sentUrl()).toBe(
'https://api-singapore.klingai.com/image-to-video/kling-4.0-flash',
);
});
it('rejects Flash last frames before submitting a task', async () => {
await expect(
generate({
model: 'kling-4.0-flash',
input_reference: 'https://example.com/frame.png',
last_frame: 'https://example.com/end.png',
}),
).rejects.toMatchObject({ statusCode: 400 });
expect(fetchSpy).not.toHaveBeenCalled();
});
it('routes Kling 4 first and last frames to image-to-video', async () => {
mockTaskFlow(succeededTask());
await generate({
model: 'kling/kling-4.0',
input_reference: 'https://example.com/frame.png',
last_frame: 'https://example.com/end.png',
seconds: 3,
});
expect(sentUrl()).toBe(
'https://api-singapore.klingai.com/image-to-video/kling-4.0',
);
expect(sentBody().contents).toContainEqual({
type: 'last_frame',
url: 'https://example.com/end.png',
});
expect(sentBody().settings.duration).toBe(3);
});
it.each(['kling-4.0', 'kling-4.0-flash'])(
'rejects an oversized prompt on %s before submitting a task',
async (model) => {
await expect(
generate({ model, prompt: 'a'.repeat(26_001) }),
).rejects.toMatchObject({ statusCode: 400 });
expect(fetchSpy).not.toHaveBeenCalled();
},
);
it("leaves Kling 4's lower non-English prompt limit to Kling", async () => {
fetchSpy.mockResolvedValueOnce(
jsonResponse(
{
code: 1201,
message:
'prompt is too long: at most 26000 English characters or 11000 non-English characters',
},
400,
),
);
const failure = await generate({
model: 'kling-4.0',
prompt: '海'.repeat(12_000),
}).catch((e) => e);
expect(sentBody().prompt).toHaveLength(12_000);
expect(translateProviderError(failure)).toMatchObject({
statusCode: 400,
legacyCode: 'upstream_bad_request',
});
expect(incrementUsageSpy).not.toHaveBeenCalled();
});
it.each(['kling-4.0', 'kling-4.0-flash'])(
'omits the unsupported audio switch on %s when audio is disabled',
async (model) => {
mockTaskFlow(succeededTask());
await generate({ model, generate_audio: false });
expect(sentBody().settings).not.toHaveProperty('audio');
},
);
});
@@ -62,12 +62,44 @@ const seconds = (def: number, min: number, max: number): number[] => [
];
// Prices are per second of output from
// https://kling.ai/document-api/pricing/base/video (1 unit = $0.14). Cost keys
// are `per-second:<resolution>`, with `:audio` for native audio and
// https://kling.ai/document-api/pricing/base/video (1 unit = $0.14) and, for
// Kling 4, https://kling.ai/dev/pricing (1 unit = $0.157). Cost keys are
// `per-second:<resolution>`, with `:audio` for optional native audio and
// `:video-input` when a source video is edited.
// `default-duration-per-video` is a 5-second clip at the default resolution,
// for cross-provider sorting and display only.
export const KLING_VIDEO_GENERATION_MODELS: IVideoModel[] = [
{
id: 'kling-4.0',
puterId: 'kling:kling/kling-4.0',
aliases: ['kling/kling-4.0'],
name: 'Kling 4.0',
costs_currency: 'usd-cents',
output_cost_key: 'default-duration-per-video',
costs: {
'per-second:720p': 15.7,
'per-second:1080p': 23.55,
'default-duration-per-video': 78.5,
},
durationSeconds: seconds(5, 3, 30),
dimensions: ['720p', '1080p'],
fps: [24],
},
{
id: 'kling-4.0-flash',
puterId: 'kling:kling/kling-4.0-flash',
aliases: ['kling/kling-4.0-flash'],
name: 'Kling 4.0 Flash',
costs_currency: 'usd-cents',
output_cost_key: 'default-duration-per-video',
costs: {
'per-second:720p': 9.42,
'default-duration-per-video': 47.1,
},
durationSeconds: seconds(5, 3, 20),
dimensions: ['720p'],
fps: [24],
},
{
id: 'kling-3.0-turbo',
puterId: 'kling:kling/kling-3.0-turbo',
@@ -186,6 +218,26 @@ export const KLING_VIDEO_GENERATION_MODELS: IVideoModel[] = [
// https://kling.ai/document-api/api/video and the capability map
// https://kling.ai/document-api/guides/capability-map/video.
export const KLING_VIDEO_SPECS: Record<string, KlingVideoSpec> = {
// Kling 4 takes 26,000 English characters but 11,000 non-English ones,
// and enforces the lower limit itself.
'kling-4.0-flash': {
textPath: '/text-to-video/kling-4.0-flash',
imagePath: '/image-to-video/kling-4.0-flash',
audio: 'always',
lastFrame: false,
maxReferenceImages: 0,
maxReferenceImagesWithVideo: 0,
maxPromptChars: 26_000,
},
'kling-4.0': {
textPath: '/text-to-video/kling-4.0',
imagePath: '/image-to-video/kling-4.0',
audio: 'always',
lastFrame: true,
maxReferenceImages: 0,
maxReferenceImagesWithVideo: 0,
maxPromptChars: 26_000,
},
'kling-3.0-turbo': {
textPath: '/text-to-video/kling-3.0-turbo',
imagePath: '/image-to-video/kling-3.0-turbo',
+6 -4
View File
@@ -34,7 +34,7 @@ An object containing the following properties:
| `stream` | `Boolean` | A boolean indicating whether you want to stream the completion. Defaults to `false`. |
| `max_tokens` | `Number` | The maximum number of tokens to generate in the completion. By default, the specific model's maximum is used. |
| `temperature` | `Number` | A number between 0 and 2 indicating the randomness of the completion. Lower values make the output more focused and deterministic, while higher values make it more random. By default, the model's own temperature is used. See [Model-specific features](#model-specific-features). |
| `reasoning_effort` / `reasoning.effort` | `String` | Controls how much effort reasoning models spend thinking. Supported values: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Lower values give faster responses with less reasoning. OpenAI models, Moonshot's Kimi K3.1 Pro models, Meta's Muse Spark models, `gemini-4-argon`, `gemini-3.1-flash-lite` and `gemini-3-flash-preview` only. See [Model-specific features](#model-specific-features). |
| `reasoning_effort` / `reasoning.effort` | `String` | Controls how much effort reasoning models spend thinking. Supported values: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Lower values give faster responses with less reasoning. See [Model-specific features](#model-specific-features). |
| `thinking` | `Object \| null` | Extended-thinking control: `{ type: "adaptive" \| "enabled" \| "disabled" \| "between_tools", budgetTokens?, display? }`. Pass `null` to send no thinking configuration at all (the model's own default); leaving it unset falls back to the legacy derivation from `reasoning_effort`. `budgetTokens` only applies to `type: "enabled"`. |
| `verbosity` / `text.verbosity` | `String` | Controls how long or short responses are. Supported values: `low`, `medium`, and `high`. Lower values give shorter responses. OpenAI models only. |
| `tools` | `Array` | Function definitions the AI can call. See [Function Calling](#function-calling) for details. |
@@ -465,11 +465,13 @@ Fast service uses Priority inference on supported text and image requests. Other
#### `temperature`
`gemini-4-argon` ignores `temperature`. `gemini-3.1-flash-lite` and `gemini-3-flash-preview` use it.
Gemini 4 Carbon (`gemini-4-carbon`), Gemini 4 Argon (`gemini-4-argon`) and Gemini 4 Hydrogen (`gemini-4-hydrogen`) ignore `temperature`. The `gemini-3.1-flash-lite` and `gemini-3-flash-preview` models use it.
#### `reasoning_effort`
`gemini-4-argon` accepts `low`, `medium` and `high`, and uses `medium` when you leave it unset. `gemini-3.1-flash-lite` and `gemini-3-flash-preview` accept `minimal`, `low`, `medium` and `high`, and use Google's default level when you leave it unset. For these three Gemini models, any other value fails with `400 bad_request`, and messages can contain text and images only.
Gemini 4 Carbon and Gemini 4 Argon accept `low`, `medium` and `high`, and use `medium` when you leave it unset. Gemini 4 Hydrogen accepts `low`, `medium`, `high` and `xhigh`, and uses `high` when you leave it unset. The `gemini-3.1-flash-lite` and `gemini-3-flash-preview` models accept `minimal`, `low`, `medium` and `high`, and use Google's default level when you leave it unset. For these five Gemini models, any other value fails with `400 bad_request`, and messages can contain text and images only.
The other Gemini models ignore `reasoning_effort`.
#### Function calling
@@ -568,7 +570,7 @@ Models with an equivalent Highspeed variant select that variant for fast service
#### `reasoning_effort`
Kimi K3.1 Pro accepts `low`, `high` and `max`, uses `max` when you leave it unset, and fails with `400 bad_request` on any other value.
Kimi K3.1 Pro accepts `low`, `high` and `max`, uses `max` when you leave it unset, and fails with `400 bad_request` on any other value. The other Kimi models ignore `reasoning_effort`.
#### Prompt Caching
+7 -1
View File
@@ -288,6 +288,8 @@ Available when using a Kling model (provider `'kling-video-generation'`). Every
| Model | Alias | Duration (s) | Resolutions | Audio | Last frame | Reference images | `inputVideo` |
|-------|-------|--------------|-------------|-------|------------|------------------|--------------|
| `kling-4.0` | | 3 to 30, default 5 | `720p`, `1080p` | Always | Yes | No | No |
| `kling-4.0-flash` | | 3 to 20, default 5 | `720p` | Always | No | No | No |
| `kling-3.0-turbo` (default) | `kling-v3-turbo` | 3 to 15, default 5 | `720p`, `1080p` | Always | No | No | No |
| `kling-3.0` | `kling-v3` | 3 to 15, default 5 | `720p`, `1080p`, `4k` | Optional | Yes | No | No |
| `kling-3.0-omni` | `kling-v3-omni` | 3 to 15, default 5 | `720p`, `1080p`, `4k` | Optional | Yes | Up to 7 | Yes |
@@ -299,6 +301,8 @@ The first resolution listed is the default. Prices are per second of output:
| Model | 720p | 1080p | 4K |
|-------|------|-------|----|
| `kling-4.0` | $0.157 | $0.2355 | |
| `kling-4.0-flash` | $0.0942 | | |
| `kling-3.0-turbo` | $0.112 | $0.14 | |
| `kling-3.0` | $0.084, $0.126 with audio | $0.112, $0.168 with audio | $0.42 |
| `kling-3.0-omni` | $0.084, $0.112 with audio, $0.126 with `inputVideo` | $0.112, $0.14 with audio, $0.168 with `inputVideo` | $0.42 |
@@ -311,7 +315,7 @@ A clip is shortened to fit the balance, as described in [Cost and clip length](#
| Option | Type | Description |
|--------|------|-------------|
| `model` | `String` | Video model to use, from the table above (full id or alias) |
| `prompt` | `String` | Up to 3,072 characters on the Kling 3.0 models, 2,500 on the others and on Kling 3.0 Turbo with `input_reference` |
| `prompt` | `String` | Up to 26,000 characters in English or 11,000 in other languages on Kling 4.0 and 4.0 Flash, 3,072 characters on the Kling 3.0 models, 2,500 on the others and on Kling 3.0 Turbo with `input_reference` |
| `seconds` | `Number` | Clip length, from the table above. Any other value falls back to `5`. Ignored with `inputVideo` |
| `size` | `String` | Resolution tier: `'720p'`, `'1080p'` or `'4k'` (case-insensitive), or `'WIDTHxHEIGHT'`. The `resolution` option is an alias |
| `width` | `Number` | Optional. Only the ratio of `width` to `height` is used, to pick the aspect ratio: `16:9`, `9:16` or `1:1`. Any other ratio gives `16:9`. A clip from `input_reference` or `inputVideo` takes the image's or video's shape |
@@ -323,6 +327,8 @@ A clip is shortened to fit the balance, as described in [Cost and clip length](#
An option the model lacks, or a combination it doesn't support, is rejected with `bad_request` before any credits are spent. Clips carry no watermark. Kling returns a hosted URL that stays available for 30 days.
On Kling 4.0 and 4.0 Flash, a prompt that mixes English with another language is within the limit when its English characters divided by 26,000 plus its other characters divided by 11,000 come to 1 or less. A prompt over 26,000 characters fails with `bad_request`. Kling rejects a shorter prompt that is over the limit for its language with `upstream_bad_request`. Neither is charged.
Kling 3.0 Omni and Kling O1 edit a video passed as `inputVideo`. The video must be MP4 or QuickTime, up to 200 MiB for a Puter file, and 3 to 15.5 seconds long on Kling 3.0 Omni or 3 to 10 seconds on Kling O1. Kling doesn't take a `data:` URI. It fetches a URL itself, and gets a Puter file as a link that works for 19 minutes, which it fetches when the job starts. A video Kling can't decode fails with `upstream_bad_request` and isn't charged. Up to 4 `reference_images` can go with the video.
For more details, see the [Kling video API reference](https://kling.ai/document-api/api/video/3-0-omni/text-to-video).
+4 -2
View File
@@ -81,7 +81,9 @@ The standard chat timeout is 10 minutes for a response to start, or to finish if
GPT-6.1 Terra has a 1,050,000-token context window and a maximum output of 128,000 tokens. Requests with more than 272,000 input tokens are charged at twice the input and cache rates and 1.5 times the output rate for the whole request.
A `gemini-4-argon` response that isn't streamed is capped at 32,768 output tokens, and a larger `max_tokens` is lowered to that cap. Streaming uses the model-directory limit.
Gemini 4 Carbon and Gemini 4 Hydrogen accept text and images within a shared 1,048,576-token window and generate up to 65,536 tokens, including thinking.
A `gemini-4-argon` or `gemini-4-carbon` response that isn't streamed is capped at 32,768 output tokens, and a larger `max_tokens` is lowered to that cap. Streaming uses the model-directory limit.
Text-to-speech calls to ElevenLabs, xAI, Speechify, Kling and Gemini time out after 2 minutes; xAI speech-to-text and voice-changer calls after 10 minutes, upload included. A call that times out before any audio or transcript comes back fails with `504 upstream_timeout`. For Gemini, the 2 minutes cover the whole reply, audio included.
@@ -209,7 +211,7 @@ A longer prompt, a larger image or video, or input over the token limit fails wi
The reservation is a conservative estimate based on verified generation usage, not a maximum charge. Google can return more output than the requested 65,536 tokens, and the charge is for the input, video, output and thinking tokens Google reports, even when that's more than the reservation. A reply that reports token usage is charged for it even when the reply failed or has no usable clip.
Kling video models take a prompt of up to 3,072 characters (Kling 3.0 models) or 2,500 (the others, and Kling 3.0 Turbo with `input_reference`). Kling 3.0 Omni and Kling O1 take a source video (`inputVideo`) as a URL or as a Puter file of up to 200 MiB, which fails with `413 input_too_large` above that. Kling fetches either one itself. A Puter file is passed as a link that works for 19 minutes. The source must be an MP4 or QuickTime video of 3 to 15.5 seconds (10 on Kling O1). Kling rejects a source outside its limits, or one it can't decode, with `upstream_bad_request`, and the request isn't charged. An edit holds the price of a 16-second clip (10 on Kling O1). Each call to Kling times out after 60 seconds, and a job is polled every 5 seconds.
Kling 4.0 and 4.0 Flash accept a prompt of up to 26,000 characters in English or 11,000 in other languages, and generate 3 to 30 seconds or 3 to 20 seconds respectively. A prompt that mixes English with another language is within the limit when its English characters divided by 26,000 plus its other characters divided by 11,000 come to 1 or less. A prompt over 26,000 characters fails with `bad_request`, and Kling rejects a shorter prompt that is over the limit for its language with `upstream_bad_request`. Neither is charged. Kling 4.0 supports 720p and 1080p, and Flash supports 720p. Other Kling video models take a prompt of up to 3,072 characters (Kling 3.0 models) or 2,500 (the others, and Kling 3.0 Turbo with `input_reference`). Kling 3.0 Omni and Kling O1 take a source video (`inputVideo`) as a URL or as a Puter file of up to 200 MiB, which fails with `413 input_too_large` above that. Kling fetches either one itself. A Puter file is passed as a link that works for 19 minutes. The source must be an MP4 or QuickTime video of 3 to 15.5 seconds (10 on Kling O1). Kling rejects a source outside its limits, or one it can't decode, with `upstream_bad_request`, and the request isn't charged. An edit holds the price of a 16-second clip (10 on Kling O1). Each call to Kling times out after 60 seconds, and a job is polled every 5 seconds.
MiniMax video models take a prompt of up to 7,000 characters (H3 models) or 2,000 (Hailuo models), and up to 5 images as frames and references together (2 on H3 Max and Hailuo 02, 1 on Hailuo 2.3 and 2.3 Fast). Hailuo 2.3 Fast requires a first-frame image. Hailuo 02 supports first and last frames together at `768p` or `1080p`, and a first frame alone at `512p`. MiniMax fetches an image URL itself, and a Puter file is sent inline. Each call to MiniMax times out after 60 seconds, and a job is polled every 5 seconds.