Skip to content
Moonshot AI logo

Kimi K2.5

Text GenerationMoonshot AIProxied

Kimi K2.5 is Moonshot AI's language model with strong coding, reasoning, and multilingual capabilities.

Model Info
Context Window128,000 tokens
Terms and Licenselink
More informationlink

Usage

TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k2.5',
{
messages: [
{
role: 'user',
content: 'Explain the difference between TCP and UDP protocols.',
},
],
},
{
gateway: { id: 'default' },
}
)
console.log(response)

Examples

With System Message — Using a system message to guide responses
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k2.5',
{
messages: [
{
role: 'system',
content:
'You are an expert in Chinese history and culture. Respond with historical context and interesting anecdotes.',
},
{
role: 'user',
content: 'Tell me about the Silk Road.',
},
],
temperature: 0.7,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Code Generation — Lower temperature for precise code output
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k2.5',
{
messages: [
{
role: 'user',
content:
'Write a Python function to calculate the Fibonacci sequence using memoization.',
},
],
temperature: 0.2,
max_tokens: 500,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Multi-turn Conversation — Continuing a conversation with context
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k2.5',
{
messages: [
{
role: 'user',
content: 'I want to learn about neural networks.',
},
{
role: 'assistant',
content:
'Neural networks are computing systems inspired by biological neural networks. They consist of layers of interconnected nodes. Would you like to start with the basics of perceptrons?',
},
{
role: 'user',
content: 'Yes, explain perceptrons first.',
},
],
max_tokens: 800,
},
{
gateway: { id: 'default' },
}
)
console.log(response)

Parameters

temperature
numberminimum: 0maximum: 2
max_tokens
numberexclusiveMinimum: 0
max_completion_tokens
numberexclusiveMinimum: 0
top_p
numberminimum: 0maximum: 1
frequency_penalty
numberminimum: -2maximum: 2
presence_penalty
numberminimum: -2maximum: 2
stream
boolean
tool_choice
response_format

API Schemas

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"system",
"developer",
"user",
"assistant",
"tool"
]
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
},
{
"type": "array",
"items": {}
}
]
}
},
"required": [
"role",
"content"
],
"additionalProperties": {}
}
},
"temperature": {
"type": "number",
"minimum": 0,
"maximum": 2
},
"max_tokens": {
"type": "number",
"exclusiveMinimum": 0
},
"max_completion_tokens": {
"type": "number",
"exclusiveMinimum": 0
},
"top_p": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"frequency_penalty": {
"type": "number",
"minimum": -2,
"maximum": 2
},
"presence_penalty": {
"type": "number",
"minimum": -2,
"maximum": 2
},
"stream": {
"type": "boolean"
},
"stream_options": {
"type": "object",
"properties": {
"include_usage": {
"type": "boolean"
}
},
"additionalProperties": false
},
"tools": {
"type": "array",
"items": {}
},
"tool_choice": {},
"response_format": {}
},
"required": [
"messages"
],
"additionalProperties": {}
}