opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(provider): add FriendliAI provider support

Open minpeter opened this issue 3 days ago • 3 comments

Summary

Add native support for FriendliAI as an OpenAI-compatible provider with proper handling of Friendli-specific features.

Changes

transform.ts

  1. variants() - Returns empty object for Friendli provider

    • Friendli uses chat_template_kwargs instead of reasoningEffort
    • Variants are defined explicitly via config or models.dev
  2. providerOptions() - Adds Friendli-specific provider options

    • Strips unsupported thinking option
    • Injects parse_reasoning: true for backward compatibility with pre-Dec 2025 models
  3. schema() - Sanitizes JSON Schema for Friendli constraints

    • Removes unsupported properties: minLength, maxLength (string), minimum/maximum (number only)
    • Filters unsupported formats (only uuid, date-time, date, time allowed)
    • Removes maxItems, clamps minItems > 1 to 1
    • Removes unsupported composition: allOf, oneOf, not (only anyOf supported)
    • Removes additionalProperties
    • Based on: https://friendli.ai/docs/guides/structured-outputs

Related

  • models.dev PR: (will be linked after creation)

Testing

Tested with local build against FriendliAI serverless endpoints:

  • ✅ Qwen3-32B with --variant off/on
  • ✅ K-EXAONE-236B-A23B with --variant off/on
  • ✅ GLM-4.6 with --variant off/on

minpeter avatar Jan 12 '26 11:01 minpeter