Skip to content
Instructor

Frameworks and SDKs

Use Instructor with Shannon

Patch an OpenAI client pointed at Shannon with Instructor and get Pydantic objects back from Shannon models, whole or streamed.

  • Tested Nov 7, 2026
  • OpenAI Chat Completions
  • About 1 min

About Instructor

Instructor turns model answers into validated Pydantic objects: you pass a response_model and get typed data back, with retries when validation fails. It wraps the OpenAI client, so pointing that client at Shannon gives structured output from Shannon models.

What you need

A Shannon API key
Keys & usage
Base URL
https://api.shannon-ai.com/v1 Endpoint: /v1/chat/completions
Every snippet below follows your choice.

Set it up

  1. Install Instructor

    Shell
    pip install instructor openai
  2. Get a typed object back

    Mode.TOOLS asks for the object through a tool call, which Shannon models support.

    Python
    import instructor
    from openai import OpenAI
    from pydantic import BaseModel
    
    client = instructor.from_openai(
        OpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY"),
        mode=instructor.Mode.TOOLS,
    )
    
    class Cat(BaseModel):
        name: str
        colour: str
        age_years: int
    
    cat = client.chat.completions.create(
        model="Kimi-K3-uncensored-NVFP4",
        response_model=Cat,
        messages=[{"role": "user", "content": "Tom is a grey cat, 4 years old."}],
    )
    print(cat)  # name='Tom' colour='grey' age_years=4
  3. Stream a partial object

    Python
    for partial in client.chat.completions.create_partial(
        model="Kimi-K3-uncensored-NVFP4",
        response_model=Cat,
        messages=[{"role": "user", "content": "Make up a cat: name, colour, age in years."}],
    ):
        print(partial)

Check that it works

Send: Run the first sample.

You should see: name='Tom' colour='grey' age_years=4

Models that fit Instructor

Every id below meets what Instructor needs. The first one is the default in the snippets.

Model idContext windowMax outputImage input
Kimi-K3-uncensored-NVFP4 1,022,976 262,144 Yes
Kimi-K3-uncensored-3BIT-REAP 225,280 225,280 Yes
shannon-3 196,608 65,536 Yes
shannon-coder-1 131,072 65,536 No

Good to know

  • Mode.TOOLS is the mode to use with Shannon; it relies on tool calls, which every model in the picker makes.
  • Wrap your own client with from_openai as shown, so the base URL and key are the Shannon ones.

Tips

  1. max_retries=2 on create re-asks the model when validation fails, at the cost of one request per retry.
  2. create_iterable returns a list of objects from one answer, for example every cat in a paragraph.
  3. Instructor also wraps the Anthropic client (instructor.from_anthropic), which can point at Shannon with base_url="https://api.shannon-ai.com"; we tested the OpenAI route.

Troubleshooting

SymptomCauseFix
InstructorRetryException The answer did not validate after the retries. Loosen the model's field types or raise max_retries.
404 Not Found base_url lacks /v1. Use https://api.shannon-ai.com/v1.
401 Unauthorized The key is missing, mistyped or rotated. Copy the key again from Keys & usage; it starts with sk-.
context_length_exceeded / "prompt is too long" The conversation is longer than the model's window. Start a new chat, let the tool compact it, or pick a model with a larger window.
insufficient_quota Your balance cannot pay for the request. Top up or change plan; the request is not retried by itself.

Questions

Does Instructor work with Shannon?

Yes: wrap OpenAI(base_url="https://api.shannon-ai.com/v1") with instructor.from_openai.

Does streaming work?

Yes; create_partial yields the object as it fills in, which we tested.

Choose your language

All languages are equal. Pick the one you want to browse in.

Europe

Middle East & North Africa

South Asia

Southeast Asia

East Asia

Central Asia & Caucasus

Africa

Oceania

Constructed & Classical