# Для разработчиков

## Python example:

Пример приведен для старой версии библиотеки openai

```python
import openai # openai==0.28

openai.api_key = "sk_xxx" # Ваш API ключ
openai.api_base = "https://eu.neuroapi.host/v1" # Наш API Endpoint


def main():
    chat_completion = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[{"role": "user", "content": "write a poem about a tree"}],
        stream=True,
    )

    if isinstance(chat_completion, dict):
        # not stream
        print(chat_completion.choices[0].message.content)
    else:
        # stream
        for token in chat_completion:
            content = token["choices"][0]["delta"].get("content")
            if content != None:
                print(content, end="", flush=True)


if __name__ == "__main__":
    main()
```

Пример для новой библиотеки:

```python
import openai # версия openai не менее 1.0

# optional; defaults to `os.environ['OPENAI_API_KEY']`
openai.api_key = 'sk_xxx' # Ваш API ключ

# all client options can be configured just like the `OpenAI` instantiation counterpart
openai.base_url = "https://eu.neuroapi.host/v1" # Наш API Endpoint
openai.default_headers = {"x-foo": "true"}

completion = openai.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "user",
            "content": "How do I output all files in a directory using Python?",
        },
    ],
)
print(completion.choices[0].message.content)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://neuroapi.gitbook.io/ru/primery-ispolzovaniya/dlya-razrabotchikov.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
