Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.subconscious.dev/llms.txt

Use this file to discover all available pages before exploring further.

Structured output lets you define a JSON schema for the model’s response, ensuring you get consistently typed data back. This uses the standard OpenAI response_format parameter.

JSON Schema

Pass a JSON schema via response_format to constrain the model’s output:
from openai import OpenAI
import json

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.subconscious.dev/v1",
)

response = client.chat.completions.create(
    model="subconscious/tim-qwen3.6-27b",
    messages=[{"role": "user", "content": "Extract the key facts from: 'Tesla reported $25.5B in Q3 2024 revenue, up 8% year-over-year.'"}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "financial_extract",
            "schema": {
                "type": "object",
                "properties": {
                    "company": {"type": "string"},
                    "revenue": {"type": "string"},
                    "period": {"type": "string"},
                    "growth": {"type": "string"},
                },
                "required": ["company", "revenue", "period", "growth"],
            },
        },
    },
)

result = json.loads(response.choices[0].message.content)
print(result)
# {"company": "Tesla", "revenue": "$25.5B", "period": "Q3 2024", "growth": "8% YoY"}

With Pydantic (Python)

Use Pydantic models to define your schema and parse the response:
Python
from openai import OpenAI
from pydantic import BaseModel
import json

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.subconscious.dev/v1",
)

class SentimentAnalysis(BaseModel):
    sentiment: str
    confidence: float
    keywords: list[str]

response = client.chat.completions.create(
    model="subconscious/tim-qwen3.6-27b",
    messages=[{"role": "user", "content": "Analyze: 'The new update is fantastic, everything runs so smoothly now!'"}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "sentiment_analysis",
            "schema": SentimentAnalysis.model_json_schema(),
        },
    },
)

result = SentimentAnalysis.model_validate_json(response.choices[0].message.content)
print(result.sentiment)    # "positive"
print(result.confidence)   # 0.95
print(result.keywords)     # ["fantastic", "smoothly"]

With Zod (TypeScript)

Use Zod schemas with zodResponseFormat from the OpenAI SDK:
Node.js
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";

const client = new OpenAI({
  apiKey: "your-api-key",
  baseURL: "https://api.subconscious.dev/v1",
});

const SentimentAnalysis = z.object({
  sentiment: z.enum(["positive", "negative", "neutral"]),
  confidence: z.number(),
  keywords: z.array(z.string()),
});

const response = await client.chat.completions.create({
  model: "subconscious/tim-qwen3.6-27b",
  messages: [
    {
      role: "user",
      content:
        "Analyze: 'The new update is fantastic, everything runs so smoothly now!'",
    },
  ],
  response_format: zodResponseFormat(SentimentAnalysis, "sentiment_analysis"),
});

const result = SentimentAnalysis.parse(
  JSON.parse(response.choices[0].message.content!)
);
console.log(result.sentiment); // "positive"

JSON Mode

For simpler cases where you just need valid JSON without a specific schema, use JSON mode:
Python
response = client.chat.completions.create(
    model="subconscious/tim-qwen3.6-27b",
    messages=[
        {"role": "system", "content": "Respond only in JSON."},
        {"role": "user", "content": "List three programming languages and their main use cases."},
    ],
    response_format={"type": "json_object"},
)
When using JSON mode without a schema, include “respond in JSON” or similar instructions in your prompt. The model needs to know you expect JSON output.