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

# Migration and Integrations

> Connect OpenAI-compatible clients, Pi, OpenCode, LangChain, Vercel AI SDK, observability tools, and desktop clients to Private AI.

Phala Private AI is OpenAI-compatible. Most integrations require changing only the base URL and API key:

```text theme={"system"}
https://inference.phala.com/v1
```

After migration, responses can be verified with `x-receipt-id`, [Attestation Report](/phala-cloud/confidential-ai/confidential-model/api-reference/attestation), and [Get Receipt](/phala-cloud/confidential-ai/confidential-model/api-reference/receipts).

## Migrate from OpenAI

```python theme={"system"}
from openai import OpenAI

# Before
openai_client = OpenAI(api_key="sk-...")

# After
phala_client = OpenAI(
    api_key="YOUR_PHALA_API_KEY",
    base_url="https://inference.phala.com/v1",
)
```

Everything else stays familiar: chat completions, streaming, tool calling, vision, structured output, and embeddings use OpenAI-compatible request shapes.

## Migrate from OpenRouter

```python theme={"system"}
from openai import OpenAI

client = OpenAI(
    base_url="https://inference.phala.com/v1",
    api_key="YOUR_PHALA_API_KEY",
)
```

Model ids use the provider/model format returned by `/v1/models`. Use `is_tee: true` to find models that can be served confidentially, then verify the actual response receipt.

## OpenAI SDK

<CodeGroup>
  ```python Python theme={"system"}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_PHALA_API_KEY",
      base_url="https://inference.phala.com/v1",
  )

  response = client.chat.completions.create(
      model="z-ai/glm-5.2",
      messages=[{"role": "user", "content": "Explain TEE privacy."}],
  )

  print(response.choices[0].message.content)
  ```

  ```typescript TypeScript theme={"system"}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.PHALA_AI_API_KEY,
    baseURL: "https://inference.phala.com/v1",
  });

  const response = await client.chat.completions.create({
    model: "z-ai/glm-5.2",
    messages: [{ role: "user", content: "Explain TEE privacy." }],
  });
  ```
</CodeGroup>

## LangChain

```python theme={"system"}
from langchain_openai import ChatOpenAI

chat = ChatOpenAI(
    model="z-ai/glm-5.2",
    api_key="YOUR_PHALA_API_KEY",
    base_url="https://inference.phala.com/v1",
)

response = chat.invoke("Explain confidential inference in one paragraph.")
print(response.content)
```

## Vercel AI SDK

```typescript theme={"system"}
import { generateText } from "ai";
import { createOpenAI } from "@ai-sdk/openai";

const phala = createOpenAI({
  apiKey: process.env.PHALA_AI_API_KEY,
  baseURL: "https://inference.phala.com/v1",
});

const { text } = await generateText({
  model: phala("z-ai/glm-5.2"),
  prompt: "Explain attestation.",
});
```

## Langfuse

```python theme={"system"}
import os
from langfuse.openai import OpenAI

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com"

client = OpenAI(
    api_key="YOUR_PHALA_API_KEY",
    base_url="https://inference.phala.com/v1",
)
```

<Warning>
  Observability tools may store prompts, responses, metadata, or traces. For sensitive data, configure redaction or self-hosting before sending production traffic.
</Warning>

For custom Node.js or Bun applications, use the [TypeScript ACI Verifier](/phala-cloud/confidential-ai/verify/typescript-sdk) to inject a pinned `fetch` and audit signed receipts in code.

## Verified Coding Agents

Pi and OpenCode can use native Phala Cloud providers that verify the ACI
workload and TLS channel before model traffic is sent, then verify each signed
response receipt before the agent finishes the turn.

### Pi

Install the provider through Pi's package manager:

```bash theme={"system"}
pi install npm:pi-provider-phala-cloud
```

Start Pi and use its native login and model picker:

```text theme={"system"}
/login phala
# choose Phala Cloud account or Phala Cloud API key
# wait for the footer to show aci-verified
/model
# search for phala/, select a model, and press Ctrl+S to save it as the default
```

Pi stores the credential, model catalog, and saved default through its native
persistence. `PHALA_AI_API_KEY` is also supported for the current process.

### OpenCode

Install the provider through OpenCode's plugin command:

```bash theme={"system"}
opencode plugin opencode-provider-phala-cloud --global
```

Restart OpenCode, then use its native provider and model pickers:

```text theme={"system"}
/connect
# select Phala Cloud and choose the account flow or API-key method
/models
# search for phala/ and select a model
```

OpenCode stores the plugin configuration and credential in its native stores.
Do not add a separate `provider.phala` block. `PHALA_AI_API_KEY` is also
supported for the current process.

Both providers expose `/phala-attestation`, `/phala-receipts`,
`/phala-receipt`, and `/phala-session` for inspecting verified evidence. These
commands are optional: connection and response verification already fail
closed automatically.

<Note>
  Changing only an OpenAI-compatible base URL does not inject ACI's attested TLS
  transport. Base-URL clients can call the API and verify receipts separately;
  use the native Pi or OpenCode provider when verification must be enforced inside
  the agent.
</Note>

## Coding Assistants and Desktop Clients

For tools that support an OpenAI-compatible provider, use:

| Setting | Value |
| - | - |
| Provider type | OpenAI compatible |
| Base URL | `https://inference.phala.com/v1` |
| API key | Your Phala API key |
| Model | Any id from `/v1/models` |

This works for tools such as Continue, Cline-compatible assistants, Cherry Studio, and other clients that let you set an OpenAI-compatible base URL.

## Migration Checklist

* [ ] Create a Phala API key.
* [ ] Change the base URL to `https://inference.phala.com/v1`.
* [ ] List models with `GET /v1/models`.
* [ ] Use `is_tee: true` for confidential-capable models.
* [ ] Capture `x-receipt-id` in raw HTTP responses when you need verification.
* [ ] Verify one representative response before production rollout.

## Related

<CardGroup cols={2}>
  <Card title="On-demand API" icon="bolt" href="/phala-cloud/confidential-ai/confidential-model/confidential-ai-api" />

  <Card title="Error Handling" icon="triangle-alert" href="/phala-cloud/confidential-ai/confidential-model/error-handling" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.