Skip to content

OpenAI-compat: from_openai Mode.JSON with base_url /v1, not from_provider openai/ #2576

Description

@cursor

Working config (from_openai + Mode.JSON + base_url /v1)

instructor.from_provider("openai/...") hits first-party OpenAI. Default OpenAI mode is tool calling. Mode.RESPONSES_TOOLS is the Responses API.

A Chat Completions host whose public catalog is GET https://api.pzero.studio/v1/models (no key) fits from_openai if base_url is the /v1 root and mode is Mode.JSON (response_format json_object).

import instructor
from openai import OpenAI
from pydantic import BaseModel

class Reply(BaseModel):
    text: str

client = instructor.from_openai(
    OpenAI(api_key="<Bearer key for that host>", base_url="https://api.pzero.studio/v1"),
    mode=instructor.Mode.JSON,
)

reply = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "Say hello as JSON"}],
    response_model=Reply,
)

Keep embeddings and multimodal off this host.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions