Skip to content

Switch from the OpenAI API to A2Intelligence

Base URL, API key and model name: how to move an existing OpenAI integration over to A2Intelligence, with examples for curl, JavaScript and Python included.

A2Genesis team
A2Genesis GmbH · Bochum
5 min read
Generated dot-pattern cover image for the article

How do you switch from the OpenAI API to A2Intelligence without rewriting your application? The good news: in most cases you only change three values. A2Intelligence offers an interface that is compatible with the OpenAI API. The official OpenAI SDKs for JavaScript and Python therefore keep working, as do many libraries built on top of them. In this guide we show you which values to change, what the calls look like with curl, JavaScript and Python, and what to watch out for when you switch.

What changes: base URL, key and model name

You need three things for the switch:

  • Base URL: https://gateway.a2genesis.de/v1 instead of the OpenAI address.
  • API key: a key from your project on the A2Genesis platform. Store it in an environment variable as usual; our examples use A2_API_KEY.
  • Model name: a2intelligence.

Everything else – the structure of requests and responses, streaming – stays the way you know it from the OpenAI API. To see which models your key may use, query the /v1/models endpoint.

What stays the same

Compatible means you neither have to learn a new SDK nor rebuild your data structures. Requests and responses have the same shape, errors come back as HTTP status codes with an error message in JSON, and streaming works through server-sent events as usual. Many frameworks and libraries that use an OpenAI client internally can also be pointed at A2Intelligence with a custom base URL. Look in your framework's documentation for an option such as "base URL" or "API base".

What changes is mainly where processing happens: your requests run on our own hardware in Bochum, Germany, and your data is not used for training. For many teams, that is exactly the reason to switch.

Switching step by step

  1. Create an account and a project. Sign in to the platform, create a project and top up your credit or choose a subscription.
  2. Create an API key. Generate a key in your project. It is only shown once, so store it straight away in your password manager or secrets store.
  3. Update your configuration. Enter the base URL, key and model name wherever you configure OpenAI today – usually in environment variables or a configuration file.
  4. Test with a simple request. Check that the response and format are correct before you switch production workflows.
  5. Move over gradually. Switch a non-critical feature first, watch answer quality, response times and costs, then move the rest.

A practical tip: the official OpenAI SDKs also read the base URL and key from the environment variables OPENAI_BASE_URL and OPENAI_API_KEY. If your application uses these variables, you can often switch without changing any code and only need to update the model name.

Examples: curl, JavaScript and Python

A2Intelligence speaks the Responses API, OpenAI's newer interface for language models. A simple request with curl looks like this:

bash
curl https://gateway.a2genesis.de/v1/responses \  -H "Authorization: Bearer $A2_API_KEY" \  -H "Content-Type: application/json" \  -d {    "model": "a2intelligence",    "input": "Erkläre die DSGVO in drei Sätzen."  }

In JavaScript with the official OpenAI SDK you only change the options when creating the client and the model name:

javascript
import OpenAI from "openai" const client = new OpenAI({  baseURL: "https://gateway.a2genesis.de/v1",  apiKey: process.env.A2_API_KEY,}) const response = await client.responses.create({  model: "a2intelligence",  input: "Erkläre die DSGVO in drei Sätzen.",}) console.log(response.output_text)

Python works the same way:

python
import osfrom openai import OpenAI client = OpenAI(    base_url="https://gateway.a2genesis.de/v1",    api_key=os.environ["A2_API_KEY"],) response = client.responses.create(    model="a2intelligence",    input="Erkläre die DSGVO in drei Sätzen.",) print(response.output_text)

The example prompt asks the model, in German, to explain the GDPR in three sentences; any language works. If your application still uses the older Chat Completions endpoint, you can keep using it as well:

bash
curl https://gateway.a2genesis.de/v1/chat/completions \  -H "Authorization: Bearer $A2_API_KEY" \  -H "Content-Type: application/json" \  -d '{"model": "a2intelligence", "messages": [{"role": "user", "content": "Hallo"}]}'

The Responses API instead of Chat Completions

If you are switching anyway, the Responses API is worth a look. Instead of a list of messages with roles, you pass an input (input) and optional instructions (instructions). The response contains the generated text directly in output_text, and you find usage details under usage. With stream: true you receive the answer in chunks, and reasoning lets you control how thoroughly the model should think.

How to rebuild existing Chat Completions calls for the Responses API step by step is covered in our article From Chat Completions to the Responses API.

What to watch out for

  • Test your prompts. Every model reacts a little differently to wording. Check your most important prompts with real examples and adjust them if needed.
  • Check supported parameters. The interface is compatible, but not every special feature of another vendor is available everywhere. The API reference lists the parameters A2Intelligence reliably supports. Test unfamiliar options before going live.
  • Keep your error handling. Timeouts, retries and limits still belong in your code after the switch.
  • Use one key per application. On the platform you can create, rename and revoke as many keys per project as you need. Separate keys make it easy to block a single access without touching your other applications.
  • Clean up old credentials. Once the move is complete, remove keys from your previous provider that you no longer need from configurations, CI variables and secret stores.
  • Keep an eye on costs. The platform shows usage per project and lets you set a monthly limit.
  • Document data protection. Switching means a new service provider. Update your record of processing activities, your data processing agreement and, if necessary, your privacy notice.

Conclusion

In most projects, switching from the OpenAI API to A2Intelligence takes minutes: swap the base URL, set a new key, change the model name. Because the interface is compatible, you can keep your SDKs, your code and your know-how. What remains is the usual care when testing your prompts and moving over step by step.

You will find all endpoints, parameters and further examples on the page about the OpenAI-compatible API of A2Intelligence.

All articles
A2Genesis team

We build A2Intelligence, operated in Germany, and support businesses with software development, AI integration and automation.

Related pages

More articles

6 min read

AI image styles (LoRA) explained

What does an AI image style do, what is behind LoRA and what should you know about licences? A clear introduction with examples from the starter set of styles.

6 min read

GDPR and AI: a checklist for businesses

How can your business use AI tools in line with the GDPR? DPA, server location, training, retention periods and documentation as a checklist you can tick off.

Trying it out takes
a few minutes.

Create an API key on the platform and test A2Intelligence directly with the Responses API.