Wind Wind / Docs
Dashboard

WindResponse

Typed interfaces for the POST /v1/chat/completions response.

TypeScript

typescript
type ContentPart =
  | { type: 'text'; text: string }
  | { type: 'image_url'; url: string; mime_type?: string; width?: number; height?: number }

interface WindResponse {
  id: string
  choices: Array<{
    message: { role: 'assistant'; content: string | ContentPart[] }
    finish_reason: string
  }>
  usage: { input_tokens: number; output_tokens: number }
  wallet: { feature_id: string; balance_before: number; balance_after: number; cost: number }
  model: string
  feature_id: string
}

const data: WindResponse = await response.json()
const { content } = data.choices[0].message

if (typeof content === 'string') console.log(content)
if (Array.isArray(content)) {
  for (const part of content) {
    if (part.type === 'text')      console.log(part.text)
    if (part.type === 'image_url') console.log(part.url)
  }
}

Swift / iOS

swift
struct WindResponse: Decodable {
    struct Choice: Decodable {
        struct Message: Decodable { let role: String; let content: WindContent }
        let message: Message
    }
    struct Wallet: Decodable {
        let featureId: String; let balanceBefore: Double
        let balanceAfter: Double; let cost: Double
    }
    let id: String; let choices: [Choice]; let wallet: Wallet; let model: String
}

let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let wind = try decoder.decode(WindResponse.self, from: data)

Error Codes

All errors are returned as JSON with an error.code field.

json
{ "error": { "code": "INSUFFICIENT_FUNDS", "message": "User wallet balance is too low." } }
Code Description
INVALID_USER_ID The windUserId does not match any Wind account.
USER_NOT_CONNECTED The user has not connected their Wind wallet to this app.
INSUFFICIENT_FUNDS User wallet balance is too low for this request.
NO_PRICING_RULE No feature rule found for the given feature_id.
INVALID_CODE Wind Connect code is invalid or expired.
CODE_ALREADY_USED Wind Connect code has already been exchanged.
INVALID_REDIRECT_URI Redirect URI is not registered for this app.
UNAUTHORIZED No Authorization header was sent.
INVALID_API_KEY API key is missing, not found, or revoked.
UNSUPPORTED_PROVIDER Use the provider/model format, e.g. google/gemini-2.5-flash.
MODEL_PRICING_NOT_FOUND Model not in pricing database — required for per_token features.