# API documentation for gurobi.jl

**URL:** https://discourse.julialang.org/t/api-documentation-for-gurobi-jl/62825
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [June 13, 2021, 5:41am UTC](https://discourse.julialang.org/t/api-documentation-for-gurobi-jl/62825 "2021-06-13T05:41:25Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)
#### Post date: [June 13, 2021, 3:12pm UTC](https://discourse.julialang.org/t/api-documentation-for-gurobi-jl/62825/3 "2021-06-13T15:12:20Z")

</div>

There is two ways to use Gurobi in Julia that you are mixing in:

```julia
# JULIA
model = Model(Gurobi.Optimizer)
Gurobi.add_vars!(model, 0.0, I, J, Gurobi.GRB_BINARY, "r_i_j")

```

The first line is using Gurobi through JuMP, which is the recommended way. Then you can create the binary variables with

```julia
@variable(model, r[I, J], Bin)

```

as detailed [in the docs](https://jump.dev/JuMP.jl/stable/manual/variables/).

The second line use the Julia wrapper of the Gurobi C interface. If you want to that interface, without JuMP, then you should not use `Model(Gurobi.Optimizer)` as this would create a JuMP model. You should not use anything from JuMP in that case, Gurobi.jl simply wraps the C-interface as is (the Julia interface is even automatically generated with [Clang.jl](https://github.com/JuliaInterop/Clang.jl)). So check the C-interface documentation in the Gurobi website.  
Again, I would recommend using the JuMP interface directly. It is much easier and will allow you to easily switch to another solver without any change to your code (except changing the line `Model(Gurobi.Optimizer)` of course)

---

_[View the full topic](https://discourse.julialang.org/t/api-documentation-for-gurobi-jl/62825)._
