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

# Language Models

> Use text generation models through the OpenAI or Anthropic compatible interface.

<Callout icon="lightbulb" color="#4885FF" iconType="regular">
  OpenAI-compatible, Anthropic-compatible, and Gemini AI Studio native protocols are all supported for text generation.
</Callout>

## OpenAI-Compatible Interface

For features not covered here, refer to the [OpenAI API Reference](https://platform.openai.com/docs/api-reference/chat/create).

### Message Roles

| Role        | Purpose                                       | Example                                            |
| ----------- | --------------------------------------------- | -------------------------------------------------- |
| `system`    | Sets the model's behavior and persona         | "You are an experienced software engineer."        |
| `user`      | The end user's input                          | "How do I reverse a string in Python?"             |
| `assistant` | Prior model responses, for multi-turn context | "You can use `s[::-1]` or `''.join(reversed(s))`." |

### Basic Conversation

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

  client = OpenAI(
      base_url="https://api.ephone.ai/v1",
      api_key="API_KEY",
  )

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[{"role": "user", "content": "Hello!"}]
  )

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

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.ephone.ai/v1",
    apiKey: "API_KEY",
  });

  const response = await client.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Hello!" }],
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

### Streaming

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

  client = OpenAI(
      base_url="https://api.ephone.ai/v1",
      api_key="API_KEY",
  )

  stream = client.chat.completions.create(
      model="gpt-4o",
      messages=[{"role": "user", "content": "Write a short poem about spring."}],
      stream=True,
  )

  for chunk in stream:
      if chunk.choices[0].delta.content:
          print(chunk.choices[0].delta.content, end="", flush=True)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.ephone.ai/v1",
    apiKey: "API_KEY",
  });

  const stream = await client.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Write a short poem about spring." }],
    stream: true,
  });

  for await (const chunk of stream) {
    if (chunk.choices[0]?.delta?.content) {
      process.stdout.write(chunk.choices[0].delta.content);
    }
  }
  ```
</CodeGroup>

### Tool Calling (Function Calling)

For more details, see the [OpenAI tool use guide](https://platform.openai.com/docs/guides/tools).

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

  client = OpenAI(
      base_url="https://api.ephone.ai/v1",
      api_key="API_KEY",
  )

  tools = [
      {
          "type": "function",
          "function": {
              "name": "get_weather",
              "description": "Get the current weather for a city",
              "parameters": {
                  "type": "object",
                  "properties": {
                      "city": {"type": "string", "description": "City name"}
                  },
                  "required": ["city"],
              },
          },
      }
  ]

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[{"role": "user", "content": "What's the weather in London?"}],
      tools=tools,
  )

  print(response.choices[0].message)
  ```
</CodeGroup>

### Response API

The OpenAI Responses API is supported for OpenAI models. See the [OpenAI Responses API docs](https://platform.openai.com/docs/api-reference/responses/create) for usage details.

<Warning>
  1. Set `OPENAI_BASE_URL` to `https://api.ephone.ai/v1`
  2. Set `OPENAI_API_KEY` to your API key
  3. Some parameters (`presence_penalty`, `frequency_penalty`, `logit_bias`, etc.) may be ignored by certain models
  4. The legacy `function_call` parameter is deprecated — use `tools` instead
</Warning>

***

## Anthropic-Compatible Interface

For features not covered here, refer to the [Anthropic API Reference](https://docs.claude.com/en/api/messages).

### Basic Conversation

<CodeGroup>
  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic(
      base_url="https://api.ephone.ai/anthropic",
      api_key="API_KEY",
  )

  message = client.messages.create(
      model="claude-opus-4-5-20251101",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello!"}]
  )

  print(message.content[0].text)
  ```

  ```javascript Node.js theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const client = new Anthropic({
    baseURL: "https://api.ephone.ai/anthropic",
    apiKey: "API_KEY",
  });

  const message = await client.messages.create({
    model: "claude-opus-4-5-20251101",
    maxTokens: 1024,
    messages: [{ role: "user", content: "Hello!" }],
  });

  console.log(message.content[0].text);
  ```
</CodeGroup>

### Streaming

<CodeGroup>
  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic(
      base_url="https://api.ephone.ai/anthropic",
      api_key="API_KEY",
  )

  with client.messages.stream(
      model="claude-opus-4-5-20251101",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Write a short poem about spring."}],
  ) as stream:
      for text in stream.text_stream:
          print(text, end="", flush=True)
  ```

  ```javascript Node.js theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const client = new Anthropic({
    baseURL: "https://api.ephone.ai/anthropic",
    apiKey: "API_KEY",
  });

  const stream = await client.messages.stream({
    model: "claude-opus-4-5-20251101",
    maxTokens: 1024,
    messages: [{ role: "user", content: "Write a short poem about spring." }],
  });

  for await (const chunk of stream) {
    if (chunk.type === "content_block_delta" && chunk.delta.type === "text_delta") {
      process.stdout.write(chunk.delta.text);
    }
  }
  ```
</CodeGroup>

### Tool Calling

For more details, see the [Anthropic tool use guide](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview).

<CodeGroup>
  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic(
      base_url="https://api.ephone.ai/anthropic",
      api_key="API_KEY",
  )

  tools = [
      {
          "name": "get_weather",
          "description": "Get the current weather for a city",
          "input_schema": {
              "type": "object",
              "properties": {
                  "city": {"type": "string", "description": "City name"}
              },
              "required": ["city"],
          },
      }
  ]

  message = client.messages.create(
      model="claude-opus-4-5-20251101",
      max_tokens=1024,
      tools=tools,
      messages=[{"role": "user", "content": "What's the weather in London?"}],
  )

  print(message.content)
  ```
</CodeGroup>

<Warning>
  1. Set `ANTHROPIC_BASE_URL` to `https://api.ephone.ai/anthropic`
  2. Set `ANTHROPIC_API_KEY` to your API key
</Warning>

***

## Gemini AI Studio Compatible Interface

Gemini models support direct calls using the official Google AI Studio API format — no conversion to OpenAI format required. Ideal for projects already using the Google `genai` SDK.

For features not covered here, refer to the [Google AI Studio API Reference](https://ai.google.dev/gemini-api/docs).

### Basic Conversation

<CodeGroup>
  ```python Python theme={null}
  from google import genai
  from google.genai import types

  client = genai.Client(
      api_key="API_KEY",
      http_options=types.HttpOptions(
          api_version="v1beta",
          base_url="https://api.ephone.ai",
      ),
  )

  response = client.models.generate_content(
      model="gemini-2.5-pro",
      contents="Hello!",
  )

  print(response.text)
  ```

  ```javascript Node.js theme={null}
  import { GoogleGenAI } from "@google/genai";

  const ai = new GoogleGenAI({
    apiKey: "API_KEY",
    httpOptions: {
      apiVersion: "v1beta",
      baseUrl: "https://api.ephone.ai",
    },
  });

  const response = await ai.models.generateContent({
    model: "gemini-2.5-pro",
    contents: "Hello!",
  });

  console.log(response.text);
  ```
</CodeGroup>

### Streaming

<CodeGroup>
  ```python Python theme={null}
  from google import genai
  from google.genai import types

  client = genai.Client(
      api_key="API_KEY",
      http_options=types.HttpOptions(
          api_version="v1beta",
          base_url="https://api.ephone.ai",
      ),
  )

  for chunk in client.models.generate_content_stream(
      model="gemini-2.5-pro",
      contents="Write a short poem about spring.",
  ):
      print(chunk.text, end="", flush=True)
  ```

  ```javascript Node.js theme={null}
  import { GoogleGenAI } from "@google/genai";

  const ai = new GoogleGenAI({
    apiKey: "API_KEY",
    httpOptions: {
      apiVersion: "v1beta",
      baseUrl: "https://api.ephone.ai",
    },
  });

  const response = await ai.models.generateContentStream({
    model: "gemini-2.5-pro",
    contents: "Write a short poem about spring.",
  });

  for await (const chunk of response) {
    process.stdout.write(chunk.text());
  }
  ```
</CodeGroup>

### Tool Calling (Function Calling)

For more details, see the [Google AI Studio function calling guide](https://ai.google.dev/gemini-api/docs/function-calling).

<CodeGroup>
  ```python Python theme={null}
  from google import genai
  from google.genai import types

  client = genai.Client(
      api_key="API_KEY",
      http_options=types.HttpOptions(
          api_version="v1beta",
          base_url="https://api.ephone.ai",
      ),
  )

  get_weather = types.FunctionDeclaration(
      name="get_weather",
      description="Get the current weather for a city",
      parameters=types.Schema(
          type="OBJECT",
          properties={
              "city": types.Schema(type="STRING", description="City name"),
          },
          required=["city"],
      ),
  )

  response = client.models.generate_content(
      model="gemini-2.5-pro",
      contents="What's the weather in London?",
      config=types.GenerateContentConfig(
          tools=[types.Tool(function_declarations=[get_weather])]
      ),
  )

  print(response.candidates[0].content.parts)
  ```

  ```javascript Node.js theme={null}
  import { GoogleGenAI, Type } from "@google/genai";

  const ai = new GoogleGenAI({
    apiKey: "API_KEY",
    httpOptions: {
      apiVersion: "v1beta",
      baseUrl: "https://api.ephone.ai",
    },
  });

  const response = await ai.models.generateContent({
    model: "gemini-2.5-pro",
    contents: "What's the weather in London?",
    config: {
      tools: [
        {
          functionDeclarations: [
            {
              name: "get_weather",
              description: "Get the current weather for a city",
              parameters: {
                type: Type.OBJECT,
                properties: {
                  city: { type: Type.STRING, description: "City name" },
                },
                required: ["city"],
              },
            },
          ],
        },
      ],
    },
  });

  console.log(response.candidates[0].content.parts);
  ```
</CodeGroup>

<Warning>
  1. Set `base_url` / `baseUrl` to `https://api.ephone.ai` (without `/v1beta` suffix — the SDK appends it automatically)
  2. Set `api_version` / `apiVersion` to `v1beta`
  3. Set `api_key` / `apiKey` to your API key
  4. Install dependencies: Python `pip install google-genai`, Node.js `npm install @google/genai`
</Warning>

## Related Links

<Columns cols={3}>
  <Card title="OpenAI Official Docs" icon="book" href="https://platform.openai.com/docs/guides/text" arrow="true" cta="View">
    OpenAI Chat Completions API reference
  </Card>

  <Card title="Anthropic Official Docs" icon="book" href="https://docs.claude.com/en/api/messages" arrow="true" cta="View">
    Anthropic Messages API reference
  </Card>

  <Card title="Google AI Studio Docs" icon="book" href="https://ai.google.dev/gemini-api/docs" arrow="true" cta="View">
    Gemini GenerateContent API reference
  </Card>
</Columns>
