# Call with the OpenAI SDK

This page assumes that your application already uses the OpenAI Python SDK. After completing it, the application receives one text response through the Genesis Chat Completions shape.

For full integration details and usage boundaries, see [Genesis SDK](../../sdk/genesis-compatible/index.md).

(sdk-genesis-openai-flow)=
## How the call progresses

Point the existing client to the Genesis API base URL, then send a chat request with the current credential and model ID. The first message in the response is the result of this call. A returned request does not establish support for every request shape, streaming mode, or tool feature.

(sdk-genesis-openai-prepare)=
## Prepare the call

Prepare the following:

| Required item | How to obtain it | Purpose on this page |
| --- | --- | --- |
| Existing OpenAI Python SDK | Use the dependency already used by the application; this page does not install or select a version | Creates the client |
| Genesis API base URL | Obtain the complete value from the Genesis connection information for the current environment | Client service address |
| Genesis access credential | Obtain it from the Genesis connection information for the current environment | Client credential |
| Available model ID | Select one from the model information for the current environment or [list models](../../../reference/api/genesis/models.md) | Selects the model for this call |

Use the version path included in the supplied base URL. Do not append another path or mix it with an address or credential for another product.

(sdk-genesis-openai-call)=
## Send a chat request

The following example creates a client and submits one text chat request. It reads the text result from the first response message.

```python
import os

from openai import OpenAI

client = OpenAI(
    base_url=os.environ["GENESIS_BASE_URL"],
    api_key=os.environ["GENESIS_ACCESS_TOKEN"],
)

response = client.chat.completions.create(
    model=os.environ["GENESIS_MODEL_ID"],
    messages=[
        {"role": "user", "content": "Explain data lineage in one sentence."},
    ],
)

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

Printed text means that this Chat Completions call returned. Do not treat empty content, a request error, or an unavailable model as a successful result; check the error and confirm that the model supports this request shape.

(sdk-genesis-openai-next)=
## Next steps

- For request fields, streaming, or error handling, see [Chat Completions](../../../reference/api/genesis/text-generation/chat-completions.md) and [streaming responses](../../../reference/api/genesis/text-generation/streaming-responses.md).
- For separate input and output objects, use [Responses](../../../reference/api/genesis/text-generation/responses.md).
- See the [OpenAI SDK boundary in Genesis SDK](../../sdk/genesis-compatible/openai-sdk.md).
