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

# LangChain

### The simplest way is to directly set environment variables as shown below

Download Address: [https://www.langchain.com/](https://www.langchain.com/)

```
API_SECRET_KEY = "sk-pvMtoVO******66249058b93C766F2D70167"
BASE_URL = "https://aihubmix.com/v1"; #Base URL for aihubmix

os.environ["OPENAI_API_KEY"] = API_SECRET_KEY
os.environ["OPENAI_BASE_URL"] = BASE_URL
```

Note: Ensure to add /v1 at the end of openai\_api\_base,

```py Python theme={null}
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(
    openai_api_base="https://aihubmix.com/v1", # Note, add /v1 at the end
    openai_api_key="sk-3133f******fee269b71d",
)

res = llm.predict("hello")

print(res)
```

Example code for using LLM to make predictions\
The core is actually in setting the key and URL\
Methods include:

1. Setting using environment variables
2. Passing in variables
3. Manually setting environment variables

```py Python theme={null}
import os
import requests
import time
import json
import time
from langchain.llms import OpenAI

API_SECRET_KEY = "your key from aihubmix";
BASE_URL = "https://aihubmix.com/v1"; #Base URL for aihubmix

os.environ["OPENAI_API_KEY"] = API_SECRET_KEY
os.environ["OPENAI_API_BASE"] = BASE_URL

def text():
    llm = OpenAI(temperature=0.9)
    text = "What would be a good company name for a company that makes colorful socks?"
    print(llm(text))

if __name__ == '__main__':
    text();
    
```

After running, você pode see the return:

```
Lively Socks.
```

***

Última atualização: 2026-06-01
