> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openference.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python (OpenAI SDK)

> Use the official OpenAI Python library or frameworks like LangChain with Openference.

# Python (OpenAI SDK & Frameworks)

## Official SDK

```bash theme={null}
pip install openai
```

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.openference.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.chat.completions.create(
    model="GLM-5.2",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
```

Streaming, tools, embeddings, and vision all work the same as with OpenAI directly.

## LangChain (example)

```python theme={null}
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.openference.com/v1",
    api_key="YOUR_API_KEY",
    model="GLM-5.2",
)
print(llm.invoke("Say hi in French").content)
```

## LlamaIndex, Haystack, etc.

Any framework that accepts an OpenAI-compatible `base_url` + `api_key` will work.

Just point them at `https://api.openference.com/v1`.
